lkml.org 
[lkml]   [1999]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: sleep_on, wake_up question
On Thu, 30 Dec 1999, Mark Mokryn wrote:

> On Thu, 30 Dec 1999, Alan Cox wrote:
>
> > Its luck on your part then. There is no provision in the system for handling
> > that race using interruptible_sleep_on, because you can construct multiple
> > correct solutions without having to hack the kernel up
>
> In this case, what good is the sleep_on stuff? Wouldn't the cleaner
> solution be to:
> 1) add an option to signal the wait queue in the wake_up function, if the
> queue is empty (or perhaps even keep it signalled, even if there are
> queued tasks).
> 2) for the sleep_on function, add an option to be immediately awoken if
> entering an already signalled queue (and clear the signal).
>
> This would hide all the ugliness, no? And prevent a lot of incorrect
> drivers being written, just because some folks didn't catch on to this
> race (e.g. Dick Johnson's posting).
>
> -Mark
>

I don't have the latest kernels installed here so the behavior may
have changed. However,

#ifndef __KERNEL__
#define __KERNEL__
#endif

#ifndef MODULE
#define MODULE
#endif
#define __DRIVER__
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/malloc.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <asm/io.h>

static struct wait_queue *wait = NULL;

int init_module(void)
{
int result;
printk("Calling wake_up_interruptible\n");
wake_up_interruptible(&wait);
printk("Returned immediately\n");
printk("Calling interruptible_sleep_on\n");
interruptible_sleep_on(&wait);
printk("Returned immediately\n");
return 0;
}
void cleanup_module(void)
{

}

This code, with 2.3.13 shows that interruptible_sleep_on does,
as previously stated, return immediately if wake_up_interruptible
was called first. Now, if the behavior has changed since 2.3.13
we certainly have a problem.


Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : The end of the world as we know it requires a new calendar.
Seconds : 133527 (until Y2K)


-
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/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.117 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site