Re: fork and process timing issue
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 05/28/04
- Next message: Stephen L.: "Re: fork and process timing issue"
- Previous message: Jens.Toerring_at_physik.fu-berlin.de: "Re: fork and process timing issue"
- In reply to: pat saunders: "fork and process timing issue"
- Next in thread: Stephen L.: "Re: fork and process timing issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 May 2004 11:29:46 -0400
In article <bc0e3bd8.0405280650.d704260@posting.google.com>,
pat.saunders@sis.securicor.co.uk (pat saunders) wrote:
> Hi,
> I am using c , unix (solaris 8) on a sun box, although question is a general
> one.
> If I have a process A that forks() and execl() a process B.
>
> pid = fork()
> switch (pid)
> case 0:
> execl (process B)
> case -1:
> error
> default:
> store pid in array
> continue with process A.
>
> This worked fine until upgraded h/w to a faster machine.
> Now, process A executes process B and process B executes alot of code before
> it tries to access its PID which process A has not had a chance to store due
> to
> no further time slices.
> My question is to avoid semphores etc, What commands can be used to force the
> processor to hand back a time slice to process A.
> Is sleep() the best option in process B.
If you want to ensure that processes run in a particular order, you
should use an explicit mutual exclusion mechanism, like a semaphore.
Anything that just tries to "give A a timeslice" is just a probabilistic
mechanism, and can result in intermittent failures when the timeslice it
gets isn't long enough.
-- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***
- Next message: Stephen L.: "Re: fork and process timing issue"
- Previous message: Jens.Toerring_at_physik.fu-berlin.de: "Re: fork and process timing issue"
- In reply to: pat saunders: "fork and process timing issue"
- Next in thread: Stephen L.: "Re: fork and process timing issue"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|