Operating Systems
Class Example Code

This page contains extra information of use to you in the Operating Systems Course.


*Sample Exam
*Sample Programs


Sample Exam

Operating Systems Sample Exam   -- These are the kind of questions you might have on an exam.. Don't take them too literally.  They are meant to show the style of question rather than the specific material.

This was the exam given at WPI on February 5, 2007  ---- CS3013_Midterm_C07.pdf

Sample Programs

Topic
Source Code
Comments
Chapter 2 - Overview SystemCallExample.s An example of a real program calling the OS
Chapter 3 - Processes signal.c
ManyProc.c, ManyProc.exe,
RunManyProc.bat, RunManyProc.sh, CreateProcessTree.sh
myForkExec.c
CanYouKillThis.c
Program to receive signals via a kill command.
Creates hundreds of processes - how many does your machine support?
Creates Child, Grandchild, etc.  where will it end?
Simple fork and exec program.
A system manager's nightmare - can you make this program terminate???
Chapter 4 - Threads ProcessOrThread.c
ProcessorThreadOrClone.c
Shows simple properties of processes and threads.
Uses processes, threads, and clones to look at properties
of shared memory, kernel threads, etc.
Performance of

Processes and Threads

                                                             LINUX                WINDOWS
THREAD      Creation                                       PerformanceOfThreads.c
                       Scheduling                                    PerformanceOfThreads.exe
PROCESS    Creation                   ProcessCreationTime.sh             ProcessCreationTime.bat
                      Scheduling                runSchedTimes.sh           runSchedTimes.bat
Chapter 5 - Scheduling
sched.c    sched.exe   RunSched.bat

 SchedTimes.c     SchedTimes.exe      
runSchedTimes.sh    runSchedTimes.bat


latency.c    latency   

 

LinuxScheduler.c  

Do identical processes get their "fair share" of CPU?    What is "fair"?

How long does it take a process to reschedule?   Or the equivalent question - how many reschedules per second can an OS/processor accomplish?

This represents a serious analysis of queueing theory. See the Scheduling chapter for details on how to run this program.

The Linux Scheduler.  In this code see:
sys_sched_yield  (our GiveUpCPU )    
schedule               (our Dispatcher)

Chapter 6 - Synchronization ThreadsRunAmock.c
ThreadsPeterson.c
ThreadsTamed.c  
An adder and subtractor each operate on a number.
Shows code from the Peterson algorithm used in class
ThreadsRunAmock --- but now using synchronization
Chapter 7 - Deadlocks DeadWrong.c     *
DeadWrongXn.c   *
DeadRight.c      *
Two threads each call mutexes - but in the wrong order.
N threads form a circular wait via mutexes
A solution that recovers from an unsafe situation
Chapter 8 - Memory Management mmapExample.c
Simple.c    *
arch.c    arch.exe  
Example of the mmap system call.
Look at how globals, stacks, and memory are virtually addressed
Understand the underlying memory structure supported by an OS
Chapter 9 - Virtual Memory
StackItHigher.c      StackItHigher.exe  
HeapItOn.c            HeapItOn.exe

VirtualMemoryCharacteristics.xls  
cpuid.c                  cpuid.exe

SimpleLoop.c     SimpleLoop.f  SimpleLoop.exe 

How much memory does an OS allocate to stacks - try it!
How much memory can you get from the heap?  Try it!

Record of what happens when we run the previous two programs on various hardware and software platforms.
Displays processor characteristics
How simple loops can affect performnace - run with vmstat or task manager to see great stuff happen.

Chapter 10 - FileSystems/IO The FAT file system
CreateManyFiles.sh
CreateManyDirectories.c
DiskWriteTimes.c
Digging around on a FAT floppy!
How many files in a directory?
What is the maximum depth of directories?
How long to write to a file>

myfork.C
myexec.C
Simple fork program.
Simple fork and exec program

pcthreads.C,
prodcons.C
Producer/Consumer with threads
Producer/Consumer with fork

mmapexample.C Example of the mmap system call.