Re: IPC and Threading in DLL
- From: "Owen Smith" <osmith@xxxxxxxxxx>
- Date: Fri, 20 Apr 2007 16:53:48 +0100
If you need to arbitate between client apps, a service is probably best (it is possible in a driver, but its easier to keep this arbitration in user mode), but if you just need to allow access to the device without any arbitration then a driver may be needed (depends on the device)
Non-driver services just cannot communicate with the hardware, ...
They can, but using the same CreateFile / DeviceIoControl / ReadFile / WriteFile mechamisms that a standalone app can use.
On Fri, 20 Apr 2007 02:14:03 +0100, Anton Bassov <AntonBassov@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I would rather write a service to communicate with the hardware, and
have each client process communicate with this service through an IPC
mechanism (socket, pipe, shared memory, whatever....).
Non-driver services just cannot communicate with the hardware, so that you
would have to write a driver, and, at this point, there would be no need for
any form of IPC - just CreateFile() and DeviceIoControl(). Furthermore, out
of all things that you have mentioned the only one that applies to app-driver
communication is shared memory. However, normally this is not the best
option, unless you need to transfer *HUGE* amounts of data at high
frequency......
Anton Bassov
"adebaene@xxxxxxxxxxxxxxxx" wrote:
On Apr 17, 9:29 am, Ezmeralda <ezmera...@xxxxxx> wrote:
> Hello,
>
> I have the following application requirements:
>
> I need to have one DLL which may be used by several
> processes at the same time. This DLL should communicate
> to hardware and make the hardware available to all
> the processes connected to the DLL.
>
> I have the following design idea in mind:
> - the first process connecting to the DLL starts a
> thread in DllMain() (DLL_PROCESS_ATTACH) which
> communicates to the hardware and puts data in
> a global shared section
> - all other processes connecting to the DLL do
> not start a thread but can access the data in
> the global section
> - when the last proccess detaches from the DLL,
> the communication-thread should be terminated
As Gary has explained, this can't work because the communication
thread is bound to the 1st process that uses the DLL, and that process
may exit before others.
I would rather write a service to communicate with the hardware, and
have each client process communicate with this service through an IPC
mechanism (socket, pipe, shared memory, whatever....). This IPC
mechanism should be encapsulated within a DLL loaded by the clients.
The service runs all the time (even when nobody is logged), and it can
arbitrate among several concurrent and/or incopatible requests from
various clients.
Arnaud
MVP - VC
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
.
- Follow-Ups:
- Re: IPC and Threading in DLL
- From: Le Chaud Lapin
- Re: IPC and Threading in DLL
- References:
- IPC and Threading in DLL
- From: Ezmeralda
- Re: IPC and Threading in DLL
- From: adebaene
- IPC and Threading in DLL
- Prev by Date: Re: modprobe for Windows?
- Next by Date: Re: IPC and Threading in DLL
- Previous by thread: Re: IPC and Threading in DLL
- Next by thread: Re: IPC and Threading in DLL
- Index(es):
Relevant Pages
|