Re: How to sleep a kernel thread?

From: Matthew Dharm (mdharm-kernel@one-eyed-alien.net)
Date: Sat Jun 03 2000 - 02:28:58 EST


Is is safe to just set the task state myself?

Spinlocks can give me mutual exclusion, but what I need to do is sleep
until there is something in the queue to process. This is a textbook
application of semaphores -- or is the kernel implementation of semaphores
not so textbook?

Matt Dharm

On Sat, Jun 03, 2000 at 08:49:02AM +0200, Francis GALIEGUE wrote:
> On Fri, 2 Jun 2000, Matthew Dharm wrote:
>
> > Hi! I'm working on the usb mass storage support for linux. For this, we
> > have a kernel thread which blocks on a semaphore (used to indicate the
> > number of commands in the queue).
> >
> > The problem is, when I block on the semaphore, the process is still marked
> > as runnable, and thus drives the load average up to 1.00. How do I sleep
> > so that I don't drive up the load? Or how do I mark the process as
> > sleeping on a semaphore for the purposes of load average calculation?
> >
>
> [ actually, I don't really know anything about kernel threads but ] my first
> guess is that blocking on a semaphore from a kernel thread doesn't set the task
> state to TASK_{UN,}INTERRUPTIBLE, this is why it keeps running.
>
> Can you use spinlocks in kernel threads? If yes, /methinks this is what you
> should use. My $0.02. Indeed, I'd appreciate being corrected.
>
> --
> fg
>
> "You can tune a filesystem but you can't tuna fish" (HP/UX' fsck manpage)
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

-- 
Matthew Dharm                              Home: mdharm@one-eyed-alien.net 
Senior Engineer, QCP Inc.                            Work: mdharm@qcpi.com

M: No, Windows doesn't have any nag screens. C: Then what are those blue and white screens I get every day? -- Mike and Cobb User Friendly, 1/4/1999

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jun 07 2000 - 21:00:16 EST