public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* SV: semaphores
@ 1999-04-21  8:10 Mikael.Ambrus
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael.Ambrus @ 1999-04-21  8:10 UTC (permalink / raw)
  To: John.Bossom; +Cc: pthreads-win32

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

	-----Ursprungligt meddelande-----
	Från:	Bossom, John [SMTP:John.Bossom@Cognos.COM]
	Skickat:	den 21 april 1999 15:36
	Till:	Ambrus Mikael
	Ämne:	RE: semaphores


	OK, that must explain it. Thanks!

	I will try your suggestions by tomorrow.

	W.k.r. Michael Ambrus

	If I understand this correctly, you decide to delay checking errno
until after calling both perror AND printf.
	printf could call any number of system level functions that can
possibly change errno.
	You are not supposed to have any intervening system calls between
the one you made and the check of errno.  I suggest you copy errno to a
local variable if you want to delay checking it...

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: SV: semaphores
  1999-04-21  3:31 Mikael.Ambrus
@ 1999-04-21 19:35 ` Ross Johnson
  0 siblings, 0 replies; 3+ messages in thread
From: Ross Johnson @ 1999-04-21 19:35 UTC (permalink / raw)
  To: Mikael.Ambrus; +Cc: pthreads-win32

On Wed, 21 Apr 1999 Mikael.Ambrus@elema.siemens.se wrote:

> 	I used cygwin GCC B20.1 ...

I think you'll find that this is the problem. Cygwin B20.1 isn't
thread-safe out of the box. The latest version of Cygwin has some
alpha level thread-safety which is not turned on by default.

Ultimately, because it aims at providing a comprehensive POSIX
environment, Cygwin will include it's own Posix threads support.
Therefore, pthreads-win32 is targeting mainly at environments that
link with the MSCRTL.

(I hope this is basically correct.)

+----------------------+---+
| Ross Johnson         |   | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra   | FAX:    +61 6 2015227
| PO Box 1                 |
| Belconnen  ACT    2616   | WWW:    http://willow.canberra.edu.au/~rpj/
| AUSTRALIA                |
+--------------------------+


^ permalink raw reply	[flat|nested] 3+ messages in thread

* SV: semaphores
@ 1999-04-21  3:31 Mikael.Ambrus
  1999-04-21 19:35 ` Ross Johnson
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael.Ambrus @ 1999-04-21  3:31 UTC (permalink / raw)
  To: rpj; +Cc: pthreads-win32

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2805 bytes --]

	-----Ursprungligt meddelande-----
	Från:	Ross Johnson [SMTP:rpj@ise.canberra.edu.au]
	Skickat:	den 21 april 1999 04:16
	Till:	Michael Ambrus
	Kopia:	'pthreads-win32 mailing list'
	Ämne:	Re: semaphores

	On Tue, 20 Apr 1999, Michael Ambrus wrote:

	> Hi,
	> I've tried the new semaphores and they seem to work fine except
that errno
	> is not properly set as Ross said.

	Are you using the 1999-04-07 snapshot? Anything before that should
	be upgraded. 
	Yes I am.
	Can you provide me with some code that illustrates the
	problem? 
	Here it comes:
	if (sem_init (&sem, 1 1) < 0) {
	      perror("sem_init");
	      printf("sem_init. errno is %d\n",errno);
	      switch (errno) {
	         case EINVAL :
	            printf("value exceeds SEM_VALUE_MAX. \n");
	            break;
	         case ENOSPC :
	            printf(" A resource required to initialize the semaphore
has been exhausted.\n 
	                     The resources have reached the limit on
semaphores, SEM_NSEMS_MAX. \n");
	            break;
	         case ENOSYS :
	            printf(" sem_init() is not supported by this
implementation. \n");
	            break;
	         case EPERM :
	            printf(" The calling process lacks the appropriate
privileges to initialize the semaphore. \n");
	            break;

	      }

	      scanf("%c",c);
	      exit(1);
	   }

	Perhaps I've misunderstood the usage of sem_init. In a manpage I
read (
http://www.doc.ic.ac.uk/~mac/manuals/solaris-manual-pages/solaris/usr/man/ma
n3r/sem_init.3r.html
< http://www.doc.ic.ac.uk/~mac/manuals/solaris-manual-pages/solaris/usr/man/m
an3r/sem_init.3r.html>  ) sem_init should return a value < 0 if an error
occurred and errno should be set with the corresponding error.

	The simple test I wrote (tests/errno1.c in the source tree)
	checks that two threads can set and retrieve values of errno
	independently. The test succeeds for MSVC (tested on WinNT) and
	Mingw32 (tested on Win98).

	I used cygwin GCC B20.1 ...

	> I'm confused about the "pshared" attribute
	> though. Should it not be != 0 if the semaphore is to be shared
between
	> processes/treads ?

	pshared should be non-zero for shared semaphores, however,
	pthreads-win32 doesn't yet support any process shared objects. So
	sem_init should return EPERM if you set pshared != 0.

	Some other thoughts..
*	pthread_delay_np ( se
http://www-server.rcnp.osaka-u.ac.jp/unix/DOCUMENTATION/HTML/AA-Q2DPC-TKT1_h
tml/thrd0384.html
< http://www-server.rcnp.osaka-u.ac.jp/unix/DOCUMENTATION/HTML/AA-Q2DPC-TKT1_
html/thrd0384.html>  ) would be nice. Is anyone working on it? 
*	What happens if sleep() is used? Is the whole process suspended, or
does other threads run?
*	POSIX queues would be nice. Is it possible to implement them with
POSIX 1003.1a semaphores?

W.k.r.
Michael Ambrus

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-04-21 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-21  8:10 SV: semaphores Mikael.Ambrus
  -- strict thread matches above, loose matches on Subject: below --
1999-04-21  3:31 Mikael.Ambrus
1999-04-21 19:35 ` Ross Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).