public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Network Nut" <sillystack@gmail.com>
To: "'Clemens Ladisch'" <clemens@ladisch.de>
Cc: <linux-kernel@vger.kernel.org>
Subject: RE: WaitForMultipleObjects/etc. In Kernel
Date: Mon, 27 Jan 2014 13:50:19 -0600	[thread overview]
Message-ID: <00d001cf1b99$026407d0$072c1770$@gmail.com> (raw)
In-Reply-To: <52E6219A.3020405@ladisch.de>

> Unrelated processes cannot directly open objects created by another
> process (with the exception of sockets and pipes, which can be created in
> the file system).  However, sharing of any file descriptor is possible by
> sending it in a control message through a Unix domain socket.

I just spent a bit more time snooping around the Internet to see what is
possible and what is not.

My gut feeling, before trying to port my application from Windows to Linux,
was that I have been using (enjoying) synchronization primitives on Windows
that are fundamental to generalized-synchronization. Most importantly, as I
mentioned initially, I do not believe that I am victim of tunnel-vision,
where my familiarity with a particular OS has biased my perception of how
synchronization should be done. On the contrary, knowing what I know about
synchronization now, if it were left to me to design a Generalized
Synchronization Model for an OS kernel from scratch, without regard for
pre-existing OS's, the model that I would devise would probably look very
similar to what the Windows engineers  did. I feel a bit bad saying this, as
my intent here is not to take a stab at Linux's synchronization model. It's
to say...I feel that I am struggling to synthesize what I regard as a
"regular model" from bits and pieces on Linux. I am convinced that, if I
were going in the other direction, from Linux to Windows, I would not have
any problem recreating, under Windows, whatever model I had been using under
Linux.

That said, I really do need to have multiple threads, each within their
respective processes, P1:T1, P2:T2, ...Pn:Tn; all blocking on what are
effectively potentially globally-named synchronization primitives
(semaphore, mutex event)...and...ideally...as each thread blocks against
multiple, potentially-named primitives, there is an option for the master
blocking function [epoll_wait, in this case], to time-out, with the
expiration for time-out being specified as an argument to the function. And
to make matters worse, sometimes, while blocking on {semaphore + event +
event +....}, I need to block, simultaneously, on asynchronous I/O.

So what I know so far is that, if my problem is to be solved:

1. epoll/epoll_wait/etc. will definitely be part of it (Thanks!)
2. I am OK with timerfd and eventfd (Thanks!)
3. Other synchronization primitives will have to be accessible vial
file-descriptor.
4. If epoll_wait is to block on asynchronous I/O, use io_set_eventfd  to
bind completion of asynchronous I/O to signaling of an eventfd
5. I can simulate system-global named mutex using shared-memory for
underlying state of mutex (POCO NamedMutex)
6. I can get named semaphore using POSIX sem_create 

It seems that the remaining problem is to get named mutex and named
semaphore to be accessible by file-descriptor.

> > BTW, the man page for epoll_wait seems to be incorrect.
> 
> <https://www.kernel.org/doc/man-pages/reporting_bugs.html>
> 
> > "The timeout argument specifies the minimum number of milliseconds
> >        that epoll_wait() will block."
> >
> > I think the word "minimum" should be "maximum".
> 
> This sentence was copied from the poll(2) man page, where the previous
> sentence says "poll() blocks until one of the events occurs".  So the word
> "block" implies that no event has occured.

So that means that it is a bug, right? Or?

Regards,

-Nut


  reply	other threads:[~2014-01-27 19:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25 22:01 WaitForMultipleObjects/etc. In Kernel Network Nut
2014-01-26 18:33 ` Clemens Ladisch
2014-01-26 22:10   ` Network Nut
2014-01-27  9:06     ` Clemens Ladisch
2014-01-27 19:50       ` Network Nut [this message]
2014-01-28  9:04         ` Clemens Ladisch
2014-01-28 21:07           ` Network Nut
2014-01-29  8:30             ` Clemens Ladisch
2014-01-30 23:49               ` Network Nut
2014-01-31 17:05                 ` Austin S. Hemmelgarn
2014-01-31 22:35                   ` Network Nut
2014-01-31 22:53                     ` Clemens Ladisch
2014-01-31 23:00                       ` Network Nut
2014-01-31 23:08                         ` Network Nut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00d001cf1b99$026407d0$072c1770$@gmail.com' \
    --to=sillystack@gmail.com \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox