The - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

The

Description:

Various standard UNIX library functions may be used ... resource usage. getrusage ... a program to obtain current resource usages for itself, or for its child ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 7
Provided by: cru6
Learn more at: http://www.cs.usfca.edu
Category:
Tags: usages

less

Transcript and Presenter's Notes

Title: The


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
  • Weve 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
    )
Write a Comment
User Comments (0)
About PowerShow.com