COMP 3000 2012 Week 5 Notes: Difference between revisions

From Soma-notes
Sdp (talk | contribs)
fixed link
Cdelahou (talk | contribs)
mNo edit summary
 
(One intermediate revision by one other user not shown)
Line 4: Line 4:
** fork()
** fork()
*** creates a new process
*** creates a new process
*** creates own distinct address space
*** different return values for parent and child
*** different return values for parent and child
*** copies state, doesn't share
*** copies state, doesn't share
Line 25: Line 26:
*** blocks until a child terminates
*** blocks until a child terminates
** waitpid(pid_t pid, int* stat_loc, int options)
** waitpid(pid_t pid, int* stat_loc, int options)
*** blocks until child with given pid terminates
*** blocks until child with given pid (process id) terminates
* process information
* process information
** compare the output of strace and ltrace
** compare the output of strace and ltrace

Latest revision as of 06:03, 6 October 2012

Processes

  • how a process starts
    • fork()
      • creates a new process
      • creates own distinct address space
      • different return values for parent and child
      • copies state, doesn't share
      • modern unix doesn't actually copy, it just pretends that it copies
        • "[...] which is the story of virtual memory." -Anil
    • execve(const char *path, char *const argv[], char *const envp[])
      • when a process runs execve, it commits suicide and hands its process over to the new execution
      • note that the arrays themselves are null terminated
      • copies state, doesn't share
      • envp are environment variables
      • file descriptors stay open
        • so if you redirect file descriptors for original process, they stay redirected
      • env
        • command that dumps environment variables
  • how a process ends
    • exit(int return)
    • wait(int* stat_loc)
      • blocks until a child terminates
    • waitpid(pid_t pid, int* stat_loc, int options)
      • blocks until child with given pid (process id) terminates
  • process information
    • compare the output of strace and ltrace
      • tells you what the library is doing before it gets to the system level
  • system calls
    • open
      • creates a file descriptor
    • close
    • read
    • write
    • seek
    • chown
      • the chgrp command uses the lchown system call
    • chmod
    • unlink
    • mmap
      • map to memory
      • forward reference to the story of virtual memory