in reply to Re^6: Help designing a threaded service
in thread Help designing a threaded service
Hm. The description was based upon the implementation of nginx server.
Which states that:
After the main NGINX process reads the configuration file and forks into the configured number of worker processes, each worker process enters into a loop where it waits for any events on its respective set of sockets.
Each worker process starts off with just the listening sockets, since there are no connections available yet. Therefore, the event descriptor set for each worker process starts off with just the listening sockets.
When a connection arrives on any of the listening sockets (POP3/IMAP/SMTP), each worker process emerges from its event poll, since each NGINX worker process inherits the listening socket. Then, each NGINX worker process will attempt to acquire a global mutex. One of the worker processes will acquire the lock, whereas the others will go back to their respective event polling loops.
Meanwhile, the worker process that acquired the global mutex will examine the triggered events, and will create necessary work queue requests for each event that was triggered. An event corresponds to a single socket descriptor from the set of descriptors that the worker was watching for events from.
*nix isn't my world, so I'll leave it to you and others to decide if your observations or the implementation of a widely used and well tested server is correct here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Help designing a threaded service (go back to sleep)
by tye (Sage) on Jan 26, 2014 at 18:51 UTC | |
by BrowserUk (Patriarch) on Jan 26, 2014 at 20:05 UTC | |
|
Re^8: Help designing a threaded service
by zwon (Abbot) on Jan 27, 2014 at 15:14 UTC | |
by BrowserUk (Patriarch) on Jan 27, 2014 at 21:08 UTC | |
by Anonymous Monk on Jan 28, 2014 at 01:22 UTC | |
by BrowserUk (Patriarch) on Jan 28, 2014 at 05:39 UTC | |
by zwon (Abbot) on Jan 28, 2014 at 15:03 UTC |