home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / programm / 4616 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  2.0 KB

  1. Path: sparky!uunet!usc!rpi!crdgw1!ge-dab!knight.vf.ge.com!happy.vf.ge.com!doug
  2. From: doug@happy.vf.ge.com (Doug Hughes)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: Multithreads in SunOS 4.1.2
  5. Message-ID: <1992Sep10.114315.4875@knight.vf.ge.com>
  6. Date: 10 Sep 92 11:43:15 GMT
  7. References: <1992Sep8.200022@hlrz24.hlrz.kfa-juelich.de>
  8. Sender: news@knight.vf.ge.com
  9. Reply-To: doug@happy.vf.ge.com
  10. Followup-To: comp.unix.programmer
  11. Organization: GE Aerospace - VF
  12. Lines: 51
  13. Nntp-Posting-Host: happy.vf.ge.com
  14.  
  15. In article <1992Sep8.200022@hlrz24.hlrz.kfa-juelich.de>, melin@hlrz24.hlrz.kfa-juelich.de (Stephan Melin) writes:
  16. > I have the following problem:
  17. > I need to write a program that runs multiple processes concurrently, eg.:
  18. > void proc(void);
  19. > void main(void)
  20. > {
  21. >   StartThread(proc);
  22. >   printf("main\n");
  23. >   ... /* some stuff to wait for the other thread */
  24. >   printf("main acknowledged\n");
  25. >   ... /* some stuff to tell the thread to go ahead */
  26. >   printf("end main\n");
  27. > } 
  28. > void proc( void)
  29. > {
  30. >   printf("proc");
  31. >   ... /* send OK to main */
  32. >   ... /* wait for main */ 
  33. >   printf("exit proc\n");
  34. > }
  35. > output should look like this:
  36. > main
  37. > proc
  38. > main acknowledged
  39. > end main / exit proc  (what ever comes first)
  40. > Synchronization, of the processes will be done by semaphores...
  41. > I have already looked at the lwp library, but I don't want to
  42. > mess with this lowlevel stuff (I don't want to write my own
  43. > scheduler). So is there any way to solve this problem in an
  44. > easy way?
  45. > Thanks in advance
  46.  
  47. Why not just fork off a process and then exec a new process? That
  48. way you can have the two processes running in parallel using the
  49. existing UNIX scheduling algorithms.  Then, all you have to write
  50. is a good producer-consumer relationship (which can be pulled out
  51. of any good OS textbook)
  52. -- 
  53.  ___            |    GE software developer
  54. ( / ) _       _,    |    doug@happy.vf.ge.com
  55. _/_/ <_>_/_/_<_>    |    uunet!crdgw1!ge-dab!happy.vf.ge.com!doug
  56.              <_>    |    2B | !2B > The_Question
  57. ________________________|______________________________________________________
  58.