COMP 3000 2012 Week 5 Notes

From Soma-notes
Revision as of 02:03, 6 October 2012 by Cdelahou (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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