2000-11-10 15:15:54

by M.Kiran Babu

[permalink] [raw]
Subject: threads


sir,
i got some doubts in kernel
programming. i am using linux 6.1 version. i want to use threads in
kernel.is it possible to use pthreads in kernel. there is one more
function kernel_thread. can i use
that function. if i use that function how to get synchonization. inmany
files it was used. but everywhere lock_kernel() and unlock_kernel()
functions are being used. if we use that commands the whole kernel gets
locked. is there any other mechanisms. or can i use that methods only. if
i can use these methods what is the syntax of kernel_thread function. the
arguments that are passing to these function are 3. i dont know what are
those three. please tell me.













2000-11-10 15:40:52

by Matti Aarnio

[permalink] [raw]
Subject: Re: threads

On Fri, Nov 10, 2000 at 08:33:29PM +0530, M.Kiran Babu wrote:
> sir,
> i got some doubts in kernel
> programming. i am using linux 6.1 version. i want to use threads in

Linux kernel versions are now running up to 2.4.0*, what is
that 6.1 ? Some distribution ? Which ?
Which kernel version you are referring into ?

> kernel.is it possible to use pthreads in kernel. there is one more
^^^^^^^^^^^^^^^^^^ NO.
> function kernel_thread.
> can i use that function.

#include <asm/processor.h>

extern pid_t kernel_thread(int (*fn)(void *), void * arg,
unsigned long flags);

> if i use that function how to get synchonization.

With mutexes, waitqueues, or spinlocks.
All kernel facilities.

> inmany files it was used. but everywhere lock_kernel() and unlock_kernel()
> functions are being used. if we use that commands the whole kernel gets
> locked.

Really ? Who says you need to lock_kernel() for starting
a kernel thread ?

> is there any other mechanisms. or can i use that methods only.
> if i can use these methods what is the syntax of kernel_thread function.
> the arguments that are passing to these function are 3.
> i dont know what are those three. please tell me.

Pick 2.4.0 sources, open them up.

Then do: "make psdocs" or "make pdfdocs" or "make htmldocs"
and you get up documents from within the system into your
source location Documentation/DocBook/ subdirectory.

You propably want to study kernel-hacking, kernel-locking,
and kernel-api documents.

(Your system needs to have DocBook, related SGML tools, and
(for PS/PDF) (La)TeX subsystem.)

/Matti Aarnio

2000-11-10 21:15:18

by Reto Baettig

[permalink] [raw]
Subject: Re: threads

lock_kernel is a special case and will not block when you call it in
order to create a new kernel thread. Look at the implementation of
lock_kernel if you have any doubts (this is true for the 2.2 kernels. I
don't know it by heart for the 2.4 kernel).

Reto

"M.Kiran Babu" wrote:
>
> sir,
> i got some doubts in kernel
> programming. i am using linux 6.1 version. i want to use threads in
> kernel.is it possible to use pthreads in kernel. there is one more
> function kernel_thread. can i use
> that function. if i use that function how to get synchonization. inmany
> files it was used. but everywhere lock_kernel() and unlock_kernel()
> functions are being used. if we use that commands the whole kernel gets
> locked. is there any other mechanisms. or can i use that methods only. if
> i can use these methods what is the syntax of kernel_thread function. the
> arguments that are passing to these function are 3. i dont know what are
> those three. please tell me.
>
>
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> Please read the FAQ at http://www.tux.org/lkml/