Operating Systems 2019W Lecture 3

From Soma-notes
Jump to navigation Jump to search


Video from the lecture given on January 14, 2019 is now available.


In Class

Lecture 3
* tutorials have started
* look in cuLearn to see your TA
  - in grades, "TA" (feedback)

* system calls!

 - we have processes
 - they are isolated (only have a virtual CPU and virtual memory)
 - to access any other resources, it must make a system call
   - system calls are requests to the kernel
 - kernel decides whether a system call is allowed or not based on
   the user and group of the process

 - file system calls
    open, read, write, lseek, (mmap), close

 - why do we only need to do GET, POST on the web, but we need to
   do a open before a read or write?

HTTP is (originally) stateless
 - server doesn't have to remember client state between requests

UNIX file API is stateful
 - maintains state between requests

file descriptors are an index into an array of file state maintained by the kernel for each process


SCS sysadmin in charge of openstack: Andrew Pullin

Processes can use file descriptors that were opened by "someone else"
 - parent process
 - "the one who execve'd me"
process 4500
 - opens file on fd 7
 - runs fork, gets 4501

process 4501
 - identical to 4500
 - so has fd 7


process 5000
running /bin/bash
 - opens file on fd 1
 - fd 1 still open for ls (running as process 5000)



#include <stdio.h>

int main(int argc, char *argv[])
        int *x;

        x = (int *) 0;

        *x = 5;


        return 0;