Re: pthread in kernel modules?

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

 



* Theodore Kim (shkim7@web.dwe.co.kr) wrote:
> Hi all,
> ?
> I was?shocked to see the codelets in some handouts.
> ?
> int init_module()
> {?? pthread_create(abc, NULL, my_thread, NULL); }
> ?
> Could this ever be possible?

No (unless kernel is patched to export a function with the above
prototype, which would be very odd).  Nothing from c library or other
userspace libraries is available in kernel code.  You'll find a few
niceties in the kernel source, for example in lib/string.c, that are
typically supplied by c library, but nothing like pthreads!

> To the best of my knowledge, only macros and static inline functions defined
> in *.h's and
> functions that are listed in 'ksyms -a' can be used in kernel module
> programming...

Yes.  From the point of view of the kernel source, if it isn't inline,
macro or exported via EXPORT_SYMBOL, it isn't available for module code.

> I used kernel_thread() several times but never ever though of using pthread
> in kernel modules.

kernel_thread would be the right thing if you want to create a thread in
a module.

-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux