Messages in this thread | | | Subject | Re: Simple driver question. | Date | Wed, 24 Nov 1999 12:13:27 +0000 (GMT) | From | Alan Cox <> |
| |
> 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/
| |