Presentation is loading. Please wait.

Presentation is loading. Please wait.

The ‘wait4()’ function Looking at how the various ‘wait()’ system-calls rely on ‘wait4()’ in the x86_64 Linux kernel.

Similar presentations


Presentation on theme: "The ‘wait4()’ function Looking at how the various ‘wait()’ system-calls rely on ‘wait4()’ in the x86_64 Linux kernel."— Presentation transcript:

1 The ‘wait4()’ function Looking at how the various ‘wait()’ system-calls rely on ‘wait4()’ in the x86_64 Linux kernel

2 ‘Waiting’ for a child-process Various standard UNIX library functions may be used by a parent-process to ‘wait’ for one of its child-processes to terminate: pid_t wait( int *status ); pid_t waitpid( pid_t pid, int *status, int options ); pid_t wait3( int *status, int options, struct rusage *rusage ); pid_t wait4( pid_t pid, int *status, int options, struct rusage *rusage ); But all of these can be built using ‘wait4()’

3 resource usage

4 ‘getrusage()’ Linux provides a library-function allowing a program to obtain current resource usages for itself, or for its child-processes which have terminated and been waited for: int getrusage( int who, struct rusage *rusage ); The ‘who’ argument is one of the symbols RUSAGE_SELF or RUSAGE_CHILDREN

5 implementation According to the ‘man’ page, ‘getrusage()’ does not currently support all of the fields defined within the ‘struct rusage’ record We have posted a short demo-program, showing fields which our current Linux kernel supports, named ‘myrusage.cpp’

6 From assembly language We’ve also posted an assembly language example in which a parent-process uses the ‘wait4()’ system-call in order to wait until its child-process has terminated; it does not make use of the ‘struct rusage’ argument however, but supplies a NULL pointer instead (see our ‘run.s’ )


Download ppt "The ‘wait4()’ function Looking at how the various ‘wait()’ system-calls rely on ‘wait4()’ in the x86_64 Linux kernel."

Similar presentations


Ads by Google