简体   繁体   中英

Error while compiling Linux kernel 2.6.39.4

I am making a system call which calculates the average waiting time in FCFS scheduling algorithm.

After following this guide, I have made changes in the concerned files and made this program. Now while compiling the kernel, it is showing this error.

CC      arch/x86/lib/strstr_32.o
  AS      arch/x86/lib/thunk_32.o
  CC      arch/x86/lib/usercopy_32.o
  AR      arch/x86/lib/lib.a
  LD      vmlinux.o
  MODPOST vmlinux.o
WARNING: modpost: Found 31 section mismatch(es).
To see
 full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
kernel/built-in.o: In function `sys_atvfcfs':
(.text+0x3e27e): undefined reference to `__floatsisf'
kernel/built-in.o: In function `sys_atvfcfs':
(.text+0x3e286): undefined reference to `__fixsfsi'
make: *** [.tmp_vmlinux1] Error 1

An this is my program

#include <linux/linkage.h>

asmlinkage long sys_atvfcfs(int at[], int bt[], int n)
{

int i=0;
int j,t,wt[n],sum,q;

float avgwt;


for(j=i+1;j<n;j++)
 {
  if(at[i]>at[j])
   {
    t=at[i];
    at[i]=at[j];
    at[j]=t;
    q=bt[i];
    bt[i]=bt[j];
    bt[j]=q;
   }
 }

wt[0]=0;
sum=0;   

for(i=0;i<n-1;i++)
{

 wt[i+1]=wt[i]+bt[i];
 sum=sum+(wt[i+1]-at[i]);

}

avgwt=sum/n;

return avgwt;
}

Can anyone explain where is the problem?

Google for "linux kernel float usage". It's a special thing. If you can avoid using floating point types, avoid it.

As the answer you've already got says, floating points are a special case for the Linux Kernel.

Specifically, one of the basic rules of the kernel is to avoid using the FPU unless you absolutely have to. To expand on what is said there:

The FPU context is not saved; even in user context the FPU state probably won't correspond with the current process: you would mess with some user process' FPU state. If you really want to do this, you would have to explicitly save/restore the full FPU state (and avoid context switches). It is generally a bad idea; use fixed point arithmetic first.

In short, as described in this question and its answers, the kernel asks the CPU not to bother with context switching the CPU registers. So if your process undergoes a context switch, the next application to run will be able to have hold of and modify your FPU registers. You'll then get back the modified state. Not good.

You can enable the fpu yourself with kernel_fpu_begin() and it is preempt-safe . However, it also disables your code from being pre-emptable and forces you into a critical section, so you must kernel_fpu_end() as soon as possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM