All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Question regarding kernel threads and userlevel
  2001-04-28  0:42 ` Steffen Persvold
@ 2001-04-28  8:32 Anton Altaparmakov
  2001-04-28  0:42 ` Steffen Persvold
  2001-05-23 16:39 ` How to time in Kernel Srinivasan Venkatraman
  0 siblings, 2 replies; 5+ messages in thread
From: Anton Altaparmakov @ 2001-04-28  8:32 UTC (permalink / raw)
  To: Steffen Persvold; +Cc: lkml

At 01:42 28/04/2001, Steffen Persvold wrote:
>I have a question regarding kernel threads : Are kernel threads treated 
>equally in terms of scheduling as normal userlevel processes ??

I'm sure someone will correct me if I am wrong but I would think that 
kernel threads are treated the same as the kernel, i.e. they are not 
pre-emptied unless you call schedule yourself or you sleep.

>kernel thread gets scheduled and tries to get the same lock it will 
>deadlock because the userlevel process never gets back control and 
>releases the lock.

It never gets pre-emptied according to the above so it would spin for ever. 
You would need a SMP system which would be running the user space code on a 
second CPU to unlock again. (And if your kernel thread is holding any other 
locks which the user mode thread will take along it's kernel code path you 
will deadlock, too.)

If my suggestion above is correct then you can fix this by doing:

while (!spin_trylock())
         schedule();

Which will forcefully schedule to allow your processes to run and you know 
that as soon as you drop out of the loop you are holding the lock. If you 
want you could also add in a counter a display a warning or something if 
you don't manage to acquire a lock after several tries, perhaps just for 
debugging purposes.

Best regards,

         Anton


-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://sourceforge.net/projects/linux-ntfs/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-05-24  7:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-04-28  8:32 Question regarding kernel threads and userlevel Anton Altaparmakov
2001-04-28  0:42 ` Steffen Persvold
2001-04-28  7:40   ` Anton Altaparmakov
2001-05-23 16:39 ` How to time in Kernel Srinivasan Venkatraman
2001-05-24  7:38   ` David Schwartz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.