home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!rpi!crdgw1!ge-dab!knight.vf.ge.com!happy.vf.ge.com!doug
- From: doug@happy.vf.ge.com (Doug Hughes)
- Newsgroups: comp.unix.programmer
- Subject: Re: Multithreads in SunOS 4.1.2
- Message-ID: <1992Sep10.114315.4875@knight.vf.ge.com>
- Date: 10 Sep 92 11:43:15 GMT
- References: <1992Sep8.200022@hlrz24.hlrz.kfa-juelich.de>
- Sender: news@knight.vf.ge.com
- Reply-To: doug@happy.vf.ge.com
- Followup-To: comp.unix.programmer
- Organization: GE Aerospace - VF
- Lines: 51
- Nntp-Posting-Host: happy.vf.ge.com
-
- In article <1992Sep8.200022@hlrz24.hlrz.kfa-juelich.de>, melin@hlrz24.hlrz.kfa-juelich.de (Stephan Melin) writes:
- > I have the following problem:
- > I need to write a program that runs multiple processes concurrently, eg.:
- >
- > void proc(void);
- >
- > void main(void)
- > {
- > StartThread(proc);
- > printf("main\n");
- > ... /* some stuff to wait for the other thread */
- > printf("main acknowledged\n");
- > ... /* some stuff to tell the thread to go ahead */
- > printf("end main\n");
- > }
- >
- > void proc( void)
- > {
- > printf("proc");
- > ... /* send OK to main */
- > ... /* wait for main */
- > printf("exit proc\n");
- > }
- >
- > output should look like this:
- > main
- > proc
- > main acknowledged
- > end main / exit proc (what ever comes first)
- >
- >
- > Synchronization, of the processes will be done by semaphores...
- > I have already looked at the lwp library, but I don't want to
- > mess with this lowlevel stuff (I don't want to write my own
- > scheduler). So is there any way to solve this problem in an
- > easy way?
- >
- > Thanks in advance
- >
-
- Why not just fork off a process and then exec a new process? That
- way you can have the two processes running in parallel using the
- existing UNIX scheduling algorithms. Then, all you have to write
- is a good producer-consumer relationship (which can be pulled out
- of any good OS textbook)
- --
- ___ | GE software developer
- ( / ) _ _, | doug@happy.vf.ge.com
- _/_/ <_>_/_/_<_> | uunet!crdgw1!ge-dab!happy.vf.ge.com!doug
- <_> | 2B | !2B > The_Question
- ________________________|______________________________________________________
-