Light weight processes : non-blocking io library changes semantics

dimitri at cui.unige.ch dimitri at cui.unige.ch
Fri Sep 21 09:55:49 AEST 1990


Has anybody on the net been using the light weight processes of the SUN
system?  I started using them and the first thing that I noticed is that
the "suggested" non-blocking io library changes the sematnics of the light
weight processes when used.  That is, while the semantics of the light
weight processes say that when the main creates a new light weight process
(with lwp_create) the new process will not run, until main has explicitly
passed control to it or has died.  This work perfectly when you anot using
the nbio library.  When you do use it, the newly created process will
start running at the moment of creation. main will be suspended until the
new process exits or explicitly passes control to it.

Here is a small program that demonstrates this.

If you compile as
	cc -o test test.c -llwp
it will run as expected: the task will start executing after the main has
exited.
If you compiler as
	cc -o test test.c -lnbio -llwp
the task will start executing the moment it is created.

Is this a bug or a feature? Any idea if it can be fixed?

----------------------------------------------------
#include <lwp/lwp.h>
#include <lwp/lwpmachdep.h>
#include <lwp/stackdep.h>
#include <stdio.h>

#define MAXPRIO 10

stkalign_t stack[MINSTACKSZ + 1000] ;

task()
{	
		fprintf(stderr,"SCHEDULER: Started\n");
}

main()
{

	thread_t tid ;

	fprintf(stderr,"Main: started\n") ;
	pod_setmaxpri(MAXPRIO);
	fprintf(stderr,"Main: starting scheduler\n") ;
	lwp_create(&tid, task , MAXPRIO-1, 0 , STKTOP(stack) , 0);
	fprintf(stderr,"Main: exiting\n") ;
}

dummy()
{
	/* this will force the use of libnbio calls */
	open () ;
}

-------------------------------------------------------------

dimitri

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dimitri Konstantas 			| UUCP : mcvax!cernvax!cui!dimitri
Centre Universitaire d'Informatique 	| EARN : dimitri at cgeuge51.bitnet
University of Geneva			| EAN  : dimitri at cuisun.unige.ch
12 rue du Lac				| Tel. : +41 (22) 787-6586
CH-1207 Geneva,SUISE			| Fax. : +41 (22) 735-3905
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-



More information about the Comp.sys.sun mailing list