Results 1 to 3 of 3
First i want to run a process in the background and as i have read to do so i have to exit its father so it will run in the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-20-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 1
Process Questions in C (fork and critical region)
First i want to run a process in the background and as i have read to do so i have to exit its father so it will run in the back
i first wrote this code
child_identity=fork();
if (child_identity>0)
{
exit(0);
}
but just as the child runs it runs the whole code again and makes an unwanted fork
In the same way i have a problem understanding the critical sections solution of Peterson ,this is the code
enter_region(process)
{
other=1-process;
interested[process]=TRUE;
turn=process;
while(turn==process&&interested[other]==TRUE)
}
when you enter the critical region
and
leave_region(process)
{
interested[process]=FALSE;
}
the process value entered in both functions is variable and based to the process that calls this function but the only number that is like this is tha number returned by fork that is 0 to the child and different to others ,still to produce such a value before all must be a fork and so all child processes will call a fork too and will ruin the code.Is there a solution.Last edited by fleshwound; 10-21-2010 at 02:00 AM.
- 10-21-2010 #2Just Joined!
- Join Date
- Dec 2009
- Location
- Maryland, USA
- Posts
- 82
Improve your thread title
The language you're programming in is probably obvious to some once they open your topic, but it would be even better if you included that info in the thread title, perhaps even repeating the info in the problem description/question.
Good luck!
- 10-21-2010 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,160
This is a school exercise or homework problem?
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
