Hi,
Le Mon, 30 Jul 2007 10:29:43 +0100 (BST),
hari krishna angadi <reachtohari@xxxxxxxxx> a écrit :
> i am porting user code as kernel code.in user code pthreads is
> used i want respective in kernel.pthread_mutex_t and
> PTHREAD_MUTEX_INITIALIZER is used in user code
Inside the kernel, there are various synchronization methods, each of
which is useful for a particular use case.
You can learn about locking in the Unreliable Guide to Locking [1],
from Rusty Russell. It however hasn't been updated since 2003, so it's
a bit out-of-date.
For a bit more up-to-date informations, you can read the Chapter 5 of
Linux Device Drivers, entitled: «Concurrency and Race Conditions» [2].
If what you're looking for is exactly mutexes, then the kernel has
mutexes. See [3] for a quick overview of the API and [4] for a
documentation of the functions. The API is fairly simple.
However, be careful: porting user code to kernel code is not always a
good idea. For what reason are you porting your code to the kernel ?
What is it doing ? Why can't it be done in userspace ?
Sincerly,
Thomas
[1] http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/
[2] http://lwn.net/images/pdf/LDD3/ch05.pdf
[3]
http://lxr.free-electrons.com/source/Documentation/mutex-design.txt#115
[4] http://lxr.free-electrons.com/source/kernel/mutex.c
--
PETAZZONI Thomas - thomas.petazzoni@xxxxxxxx
http://{thomas,sos,kos}.enix.org - Jabber: thomas.petazzoni@xxxxxxxxx
http://{agenda,livret}dulibre.org - http://www.toulibre.org
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E 1624 F653 CB30 98D3 F7A7
Attachment:
signature.asc
Description: PGP signature