Lecture 1 Goal is to show what the OS does through REAL CODE examples. The goal here is to show some interesting things the OS does, without getting into TOO MUCH detail about how it all works (that is for the class, after all). EXAMPLES: cpu.c: just something you can run one instance of first, and then a bunch of at once, in order to show that the CPU can be VIRTUALIZED. Amazingly, the OS can make it seem like you have as many CPUs as you need! e.g., prompt> cpu A mem.c: same thing but showing how you can seemingly access the "same" memory location from different programs, and yet they each seem to have their own copy. Yes, the OS can VIRTUALIZE memory too, providing each running program with the illusion of its own memory. MLC: To disable randomization for a shell session: setarch i386 -RL tcsh threads.v0.c: shows that a concurrent program, when run without locks, does weird stuff. explain how the program should work, and then ask the students what should happen. Then run it with increasing loop counts until a weird answer turns up! Explain a bit what is going on; show the disassembled code (using objdump on linux, or otool on mac) to show the load/add/store non-atomic sequence. threads.v1.c: This is the fixed version with locks. Give a high-level overview of what is going on here. threads-hello.c: This is actually used *later* in the class when pthreads are introduced. io.c: Show how this little program, which does so little to access a file from the perspective of C, actually leads to hundreds and hundreds of calls within the OS to commit the data to disk. The dtrace trace is included if you just want to look at that (iotrace.out), as well as the dtrace code (trace-io.d). Run the dtrace (on a mac) with 'dtrace -s trace-io.d' ---- After the examples, it is nice to discuss the OS's major role as providing a VIRTUAL MACHINE and all this entails. Present some of the key issues (efficiency, protection, etc.). ---- threads-v0.objdump - this file is actually used for a later lecture, when the critical section/race condition is dived into.