[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Semaphore again



S P wrote:
>  > gcc -Wall -D__KERNEL__ -I /usr/src/linux-2.4.7-10/include Sema_Try.c
> /tmp/ccSdPsrY.o(.text/lock+x): undefined reference to 
> '__down_failed_trylock'
> collect2: ld returned 1 exit status

You are trying to compile a runnable program in user-space with 
direct calls to kernel-space functions. That's generally not possible.

In this case, gcc is asking you where to find the library where 
__down_failed_trylock is defined. It's not only looking for the 
header file where it is declared, but also the library file where 
the binary definition of that function is defined. Of course you 
can't find it. Because that function never meant to be in a 
seperable library where a user-space program could link to.

So, back to your question, you want to try your understanding of the 
kernel semaphores, then you could try write a loadable kernel 
module. Go check out the kernel module programming HOW-TO. You could 
write your test code in your kernel module. Of course it is more 
dangerous than with a user-space program. But that's why kernel 
programming is harder and more fun. 8)

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/