CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005
    Posts
    79

    concurrent operations

    Hi, first please pardon me if my post is in the wrong section.. correct me please.

    I would like to understand how the to make 2 processes (in UNIX environment )work in parallel ( like cobegin)
    and when they are done, a Unix semaphore signal is called so the a third process starts doing its operations.

    say p1 (process 1) is doing a+b
    say p2 (process 2) is doing d+c

    when they have both finished, then p3 (process 3) starts doing its thing.

    I was thinking using fork() since it creates a duplicate of the program. I am not sure it is sufficient to generate a cobegin action

    Also how to use Unix semaphore to synchronize all those processes?
    I want that each process has a semaphore associate with it.

    Please can someone help me to clarify this issue like some kind of pseudo code?
    Thank you

  2. #2
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    47

    Re: concurrent operations

    Quote Originally Posted by brad sue View Post
    Hi, first please pardon me if my post is in the wrong section.. correct me please.

    I would like to understand how the to make 2 processes (in UNIX environment )work in parallel ( like cobegin)
    and when they are done, a Unix semaphore signal is called so the a third process starts doing its operations.

    say p1 (process 1) is doing a+b
    say p2 (process 2) is doing d+c

    when they have both finished, then p3 (process 3) starts doing its thing.

    I was thinking using fork() since it creates a duplicate of the program. I am not sure it is sufficient to generate a cobegin action

    Also how to use Unix semaphore to synchronize all those processes?
    I want that each process has a semaphore associate with it.

    Please can someone help me to clarify this issue like some kind of pseudo code?
    Thank you
    I guess you need only to google a little bit, you can find this: http://www.unix.com/high-level-progr...processes.html

    However, if you are new to concurrency, I'd suggest you to use the pipe, the second example (in the link), which I usually do. Fork is very useful, for the fact that it is very simple and easy to synchronize using pipe.
    Xander Tan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured