What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

Frank Chang

I would like to know the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library as described in this URL, http://home.cablesurf.de/rdengler.

If I am not mistaken, Richard Dengler's emulation of WaitForMultipleObjects is a hybrid between the event model when waiting for ANY event and the fork-join model when waiting for ALL events.[EDIT, Please correct me if I am wrong about this statement.]

Quoting from "Porting of Win32 API WaitFor to Solaris " by Nagendra Nagarajayya and Alka Guptahttp in this URL: madchat.fr/windoz/coding/winapi/waitfor_api.pdf,

A thread can wait for multiple objects to be set in one of two ways: 1. ALL The issuing thread will unblock after ALL objects specified in the call have been set. This is fairly simple to emulate. Each object is waited for in turn until all have been set or until timeout occurs. At that point this function returns.

  1. ANY The issuing thread will unblock after ANY one specified object in the call has been set

    WaitForMultipleObjects for the case ANY is the most difficult of all Win32 routines to emulate since UNIX does not support anything like it. The problem is that the issuing thread has to actually be blocked on a single Solaris variable, yet the setting of any one of a series of NT objects has to result in the signaling of that variable.[EDIT What does that mean in laymen's language?]

Following is a list of requirements for the solution:

  1. More than one thread could be waiting at any one time on same handle.

  2. Spurious signals may not be sent to threads. Note: For example, if thread 1 is waiting on two handles, A and B, and thread 2 is waiting on two handles A and C, and handle B is set, a signal may not be sent to thread 2 just because it is waiting on handle A common to threads 1 and 2.

  3. No polling

The solution detailed in this paper makes use of the subscription model, that is, the interested thread subscribes itself to the interested wait object and goes to sleep until signaled.

The model proposes that each thread that issues or executes on a WaitForcall on any one or more handles subscribes itself to those handles by adding a pair of mutex/condition variable to that handle list and then waits on that mutex/condition variable pair.

When a handle is set, all threads waiting on that handle are signaled. Thus, if two threads wait on a handle, there will be two elements in the list of that handle. And when the handle is set, both of the threads are signaled.

LIMITATION

  1. Synchronized objects states are not modified. In other words, they are not non-signaled. [EDIT What is being said here?]

  2. Named handles require the handles to reside in shared space, and could be acted upon by other processes. This requires that the mutex and condition variables be created with system scope (the threads are already created with system scope). The shared space could be memory mapped on startup and shared by different processes.[EDTT Please explain this apparently important point.]

  3. Handles can be closed multiple times and need to be freed when the reference count goes to zero.

  4. There is no check for duplicate handles.

  5. Handle type is not checked.

    Finally, please show using C/C++ code the correct way to use Mr. Richard Dengler's port of WaitForMultipleObjects in an Ubuntu or Centos application program.

    Any help is greatly appreciated.


--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

Liam Proven
On 11 October 2016 at 17:21, Frank Chang <[hidden email]> wrote:
> I would like to know the strength and weaknesses of Richard Dengler's C++
> emulation of WIN32's WaitForMultipleObjects using the pthreads library as
> described in this URL, http://home.cablesurf.de/rdengler.


O_o

It is possible that someone here might have comments about this, but
this is the ubuntu-users mailing list, a place for community support
of users of the desktop distro.

You might have more luck with the developers' list, but I am not sure
that even that is relevant. Is this Ubuntu related at all?


--
Liam Proven • Profile: http://lproven.livejournal.com/profile
Email: [hidden email] • GMail/Twitter/Facebook/Flickr: lproven
Skype/MSN: [hidden email] • LinkedIn/AIM/Yahoo: liamproven
Cell/Mobiles: +44 7939-087884 (UK) • +420 702 829 053 (ČR)

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

Karl Auer
In reply to this post by Frank Chang
On Tue, 2016-10-11 at 11:21 -0400, Frank Chang wrote:
> I would like to know the strength and weaknesses of Richard Dengler's
> C++ emulation of WIN32's WaitForMultipleObjects using the pthreads
> library as described in this URL, http://home.cablesurf.de/rdengler.

1: Your question has nothing to do with Ubuntu.

2: We are not here to do your college assignments for you.

Regards, K.

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer ([hidden email])
http://www.biplane.com.au/kauer
http://twitter.com/kauer389

GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4




--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

Liam Proven
On 11 October 2016 at 23:03, Karl Auer <[hidden email]> wrote:
> 2: We are not here to do your college assignments for you.


Ha! That didn't occur to me. :-)

--
Liam Proven • Profile: http://lproven.livejournal.com/profile
Email: [hidden email] • GMail/Twitter/Facebook/Flickr: lproven
Skype/MSN: [hidden email] • LinkedIn/AIM/Yahoo: liamproven
Cell/Mobiles: +44 7939-087884 (UK) • +420 702 829 053 (ČR)

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
Reply | Threaded
Open this post in threaded view
|

Re: What are the strength and weaknesses of Richard Dengler's C++ emulation of WIN32's WaitForMultipleObjects using the pthreads library?

Gilles Gravier-2
This was also posted here : http://stackoverflow.com/questions/39969442/what-are-the-strength-and-weaknesses-of-richard-denglers-c-emulation-of-win32 :)

Definitely looks like a college / class assignment... it's just missing the grading info. How many points for each question?

Gilles

On Wed, Oct 12, 2016 at 1:12 AM, Liam Proven <[hidden email]> wrote:
On 11 October 2016 at 23:03, Karl Auer <[hidden email]> wrote:
> 2: We are not here to do your college assignments for you.


Ha! That didn't occur to me. :-)

--
Liam Proven • Profile: http://lproven.livejournal.com/profile
Email: [hidden email] • GMail/Twitter/Facebook/Flickr: lproven
Skype/MSN: [hidden email] • LinkedIn/AIM/Yahoo: liamproven
Cell/Mobiles: <a href="tel:%2B44%207939-087884" value="+447939087884">+44 7939-087884 (UK) • <a href="tel:%2B420%20702%20829%20053" value="+420702829053">+420 702 829 053 (ČR)

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



--
Gilles Gravier - [hidden email]
Using Google Apps web mail

--
ubuntu-users mailing list
[hidden email]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users