]> git.itanic.dy.fi Git - rrdd/commit
process.c: Implement support for limiting number of active processes
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 15 Apr 2012 18:08:26 +0000 (21:08 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 15 Apr 2012 18:17:31 +0000 (21:17 +0300)
commitfada7dd5b830404fec624808a43956c29aa987ba
treefad995ba4c2439a16779c37f2e63607d03bf050f
parent6fcf40fbc57c0c89760535e4d808984688b39a5e
process.c: Implement support for limiting number of active processes

This will make it possible to have only limited number of active job
processes runnint at given time. These can be requested by calling
do_fork_limited(), which works otherwise similarly to do_fork() but
the child process will not start running until the main parent has
given the child permission to run.

The job controlling is implemented via pipes between the parent and
the children. The child which wish to limit the number of processes
will send its pid to the parent. The master parent will keep count of
all the processes running. If the number of active processes grows too
high, no new jobs are granted until fewer processes are running. Once
the parent decides that a new job can become active, it will write one
byte to a pipe. The child which reads the byte out is the one who has
the right to execute. Other children reading the same pipe are left
waiting for their turn.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
process.c
process.h