Re: Linux and OS wide events



neelsmail@xxxxxxxxxxxxxx writes:
I am not sure how I can do this. Use dbus but use my own daemon?

On 8月13日, 下午7时47分, Rainer Weikusat <rweiku...@xxxxxxxxxxx> wrote:
Josef Moellers <josef.moell...@xxxxxxxxxxxxxxxxxxx> writes:
neelsm...@xxxxxxxxxxxxxx wrote:

[...]

- App that wants to receive a event loads a DL(L).
- Adds itself as a subcriber
- Shared library keeps track of all the event subscribers (This is
where I am stuck at) and once event is fired, sends the notification.
In windows, in theory, I should be able to do it using DLLs with
shared segment

[...]

As Jens writes, two processes do share read-only code but do not share
writable data ... in general.
You could do what you want with a shared memory segment, but (without
thinking it through to the end), I would estimate that process
synchronization and storage management will be a nightmare.

This could be done fairly easily by using a file-backed shared memory
segment (aka 'mmaped file') and either ordinary POSIX record locks
(fcntl + F_SETLK &) or process-shared pthread synchronization objects
(if 'needs NPTL' is ok, should be faster).

Replies actually do make sense but I see couple of things wanting in
the design I have in mind and one that will result if I use memory
mapped files:

- The event will be "pull" rather than "push"
- I will have to specify what semaphore (that's the interprocess
communication I believe you are referring to on Linux) other processes
need to wait on.

I was refering to what I was writing about (strange coincidence, isn't
it?): POSIX record locks (see fcntl(2)) or process-shared pthread
synchronization objects. The former would be an ordinary 'file lock'
acquired on the file descriptor refering to the shared segment and the
latter are normal mutexes created somehwere inside the shared segment,
eg at offset 0.
.