Home:ALL Converter>Starting and stopping a forked process

Starting and stopping a forked process

Ask Time:2008-12-23T09:49:45         Author:titaniumdecoy

Json Formatter

Is it possible for a parent process to start and stop a child (forked) process in Unix?

I want to implement a task scheduler (see here) which is able to run multiple processes at the same time which I believe requires either separate processes or threads.

How can I stop the execution of a child process and resume it after a given amount of time?

(If this is only possible with threads, how are threads implemented?)

Author:titaniumdecoy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/387949/starting-and-stopping-a-forked-process
Iocio :

You could write a simple scheduler imitation using signals.\nIf you have the permissions, then stop signal (SIGSTOP) stops the execution of a process, and continue signal (SIGCONT) continues it.\n\nWith signals you would not have any fine grained control on the \"scheduling\",\nbut I guess OS grade scheduler is not the purpose of this execersice any way.\n\nCheck kill (2) and signal (7) manual pages.\nThere are also many guides to using Unix signals in the web.",
2008-12-23T02:22:50
Charlie Martin :

You can use signals, but in the usual UNIX world it's probably easier to use semaphores. Once you set the semaphore to not let the other process proceed, the scheduler will swap it out in the normal course of things; when you clear the semaphore, it will become ready to run again.\n\nYou can do the exact same thing with threads of course; the only dramatic difference is you save a heavyweight context switch.",
2008-12-23T02:33:07
yy