lkml.org 
[lkml]   [1999]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Simple driver question.
Date
From
> process 2 before process 1 completes the outb.  Does the kernel handle
> this case or should the driver? What mechanism would the driver use
> to handle it.

If your task doesn't sleep it won't be pre-empted. However on an SMP box
they might run in parallel one day.

You can either use spinlocks or semaphores. spinlocks can only be held for
short durations (ideally anyway) but have very very low overhead. A semaphore
can be held without impacting overall system efficiency.

In your case I'd probably use a spin lock like so

spinlock_t ioaccess_lock;

get_user(...)
spin_lock(&ioaccess_lock);
outb(foo)
outb(bar)
spin_unlock(&ioaccess_lock);

init:
spin_lock_init(&io_access_lock);

See the 2.3.x radio drivers for some fairly simple examples


-
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.042 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site