Re: async i/o question
- From: Jan Kandziora <jjj@xxxxxx>
- Date: Sun, 04 Nov 2007 00:53:40 +0100
anatolik schrieb:
There could be several application working with same kernelThen you just misuderstood how the kernel works when processing read(),
module at the same time.
write() etc.: In process context, the kernel isn't like an application,
it's like a library.
Second, there are interrupt routines.
Usually a driver has both things implemented. A part which works in process
context and a interrupt routine part which does all the work with the
hardware, both communicating through command/data queues.
In process context, your kernel driver has to ensure it does not use single
global resources, but take them from a pool instead. Each time your device
file is being opened by an application, your driver module has to allocate
and initialize some memory for your buffers and control variables which
belong to the file descriptor of open(). On close(), your driver has to
free that ressources. Inbetween, all the read(), write() etc. calls the
application makes are passing the file descriptor to your driver module,
which can look up the data structure from it. Voila, concurrency enabled by
design.
If you have some single ressource which cannot be shared (e.g. a physical
port), you have to *lock* it some way. Usual way is to implement either a
lock on the device node itself, so the device node cannot be opened more
that *once*, or (better) to implement two command/data buffer queues, which
are filled by write() and emptied by an interrupt routine on sending from
the first queue and vice versa on receiving from the second queue. The
actual port operation is done by the interrupt routine alone.
Kind regards
Jan
.
- References:
- async i/o question
- From: anatolik
- Re: async i/o question
- From: Rainer Weikusat
- Re: async i/o question
- From: anatolik
- async i/o question
- Prev by Date: Re: USB SET_DESCRIPTOR_TO_DEVICE ??
- Next by Date: Re: USB SET_DESCRIPTOR_TO_DEVICE ??
- Previous by thread: Re: async i/o question
- Next by thread: Re: async i/o question
- Index(es):
Relevant Pages
|