lkml.org 
[lkml]   [1999]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: down_interruptible and timers
On Sat, 23 Jan 1999, Tim Waugh wrote:

> Here's a code snippet from a module I'm compiling against the 2.2.0-pre9
> source:

*snip*

> add_timer (&timer);
>
> printk (KERN_DEBUG "down_interruptible returned %d\n",
> down_interruptible (&port->ieee1284.sem));
>
> del_timer (&timer);

You are not initializing right semaphores. Reading the code it seems that
sema_init() has to be used only once the semaphore has just a sense.
sema_init only change the level of the atomic counter but you could have
wakers == ~0UL on the random stack ;). So it worked by luck all the time
;))

Here the fix for your latest code (that I merged last night).

Index: parport_ieee1284.c
===================================================================
RCS file: /var/cvs/linux/drivers/misc/parport_ieee1284.c,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 parport_ieee1284.c
--- parport_ieee1284.c 1999/01/25 00:50:40 1.1.2.6
+++ linux/drivers/misc/parport_ieee1284.c 1999/01/25 14:22:01
@@ -281,11 +281,10 @@
ssize_t write_block (struct parport *port, const void *buffer, size_t len,
parport_write_block_fn fn)
{
- struct semaphore sem;
+ struct semaphore sem = MUTEX_LOCKED;
struct callback_info info = { &sem };
int error;
/* Start the writing operation. */
- sema_init (&sem, 0);
error = fn (port, buffer, len, callback, &info);

if (error)
@@ -300,12 +299,11 @@
ssize_t read_block (struct parport *port, void *buffer, size_t len,
parport_read_block_fn fn)
{
- struct semaphore sem;
+ struct semaphore sem = MUTEX_LOCKED;
struct callback_info info = { &sem };
int error;

/* Start the reading operation. */
- sema_init (&sem, 0);
error = fn (port, buffer, len, callback, &info);

if (error)
Index: parport_share.c
===================================================================
RCS file: /var/cvs/linux/drivers/misc/parport_share.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 parport_share.c
--- parport_share.c 1999/01/25 00:50:40 1.1.2.2
+++ linux/drivers/misc/parport_share.c 1999/01/25 14:21:25
@@ -111,7 +111,7 @@
spin_lock_init(&tmp->pardevice_lock);
tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
- sema_init (&tmp->ieee1284.sem, 0);
+ tmp->ieee1284.sem = MUTEX_LOCKED;
tmp->ieee1284.timeout = 5 * HZ;

name = kmalloc(15, GFP_KERNEL);


Please Tim tell me if you can reproduce the weirness also with this patch
applyed.

Andrea Arcangeli


-
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:49    [W:0.057 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site