CS40 Operating Systems

David Morgan
Santa Monica College
see syllabus for email address


Administrativa

Syllabus
Grade information

Information

Stallings book's site
 7th edition
 6th edition
 5th edition

Remote Unix access with telnet

Remote Unix access with ssh

Using ftp

Caching

Linux links
Linux man pages

Fundamental Unix Commands

System calls

Disks & booting:
 - Partitioning primer
 - Linux loader doc
 - Comparative MBRs
 -Interpreting Partition Records
 - Future of BIOS

Sys. architecture
(disk organization)

Punched cards

Memory mgmt:
 - Segmentation
 - Page replacement
 - Intel architecture (pdf)
 - Management types

Code relocation

Overlays
 - code composition
 - memory organization 

Threads

Deadlock example

Filesystem analysis

Files vs devices

Foundation concepts:

ASCII chart

Sys. architecture (interrupts)

Sys. architecture
(disk organization)

Number bases:
  -Hex tutorial
  -Hex advocacy
  -Binary numbers
  -Number systems
conversion tools:
  Table, or
  Calculator
   - binary
   - hexadecimal

 Instruction sets
   -Intel instruction set
   -Intel chip architecture

  -Others
  -CPU registers
  -a CPU instruction

An assembler program
  -source code
  -explanation 

Symbol management

Data structures
  - Datastructures
  - Linked list of states

Compile/link/load

Slide presentations

Stallings TEXTBOOK's:

Background
Ch 1 Computer Overview
Ch 2 OS Overview

Processes
Ch 3 Process
Ch 4 Threads
Ch 5 Concurrency
Ch 6 Concurrency

Memory
Ch 7 Mem Mgmt
Ch 8 Virtual Mem

Scheduling
Ch 9 Scheduling
Ch 10 Scheduling

I/O & Files
Ch 11 I/O Mgmt
Ch 12 File Mgmt


PROFESSOR's:

OS Installation

Memory Mgmt

Process Mgmt

Datastructures

Linux landscape

linux process scheduling

 

SPRING 2012
Section 4104 6:30p - 9:35p Fri Bus 259

This Website (http://homepage.smc.edu/morgan_david/)  will be used extensively to communicate with you. Announcements, grade reports, and assignments will be posted here. Please access the website from any SMC computer lab. Alternatively, it can be viewed from an internet-connected browser anywhere. You are responsible for awareness of the information posted here.

Context - put the different types of memory management we are talking about into this context.

For overlays, see link at left under heading entitled "Overlays". (5/15)

Online lecture posted listen before Friday - I have posted an online lecture on Chapter 7 Memory Management. Please be sure to listen to it by next Friday's class. We will build upon it in Chapter 8 Virtual Memory. The topic is substantial, important, unfamiliar, and challenging. Read the chapter and listen to the lecture. It is 50-60MB in size and requires Flash player to view. (5/13)

Test and lecture tonight - test will be administered by Prof. Harold Rogler (I will be absent). Also, when I've completed it, I will post here an online lecture for you to listen to, about memory management, based on textbook chapter 7. Please check back here for it in the coming few days. (5/11)

Homework
read - textbook chapter 7. (5/11)

Test - next Friday5/11, covering all material studied so far. (5/4)

Homework
read - textbook chapter 4, section 4.1 only, on the subject of threads. (5/4)

Linux process scheduling materials -
slides - at the link, lower-left, entitled "linux process scheduling". 
demonstration programs - as shown in class, with a readme file explaining how to use them, in file "process_priority.zip" available from sputnik as described in the post entitled "Distributing files to you from sputnik" at the bottom of this page.
in-class exercise - at the link, lower-right, entitled "process scheduling"
reading - commentary by scheduler author Ingo Molnar
article from ibm developerworks. (4/27)

Process scheduler video animation we watched in class. (4/27)

Of possible interest - this summer two US Cyber Challenge camps will be held at Cal Poly Pomona July 16-20 and August 6-10.  Students will need to score well in an on-line competition to receive an invitation for the camp.

Information on the camp is available at https://www.nbise.org/uscc/events/camps and http://uscc.cyberquests.org/. (4/23)

Homework
read - textbook chapters we are covering now on the topic of processes. Those are chapters 3 and 9 (process scheduling). You don't need to read much of chapter 9, just enough to enable assignment 9.
do - assgt 9, after I have demonstrated how to do it in class. (4/20)
In class I demonstrated it in essence but not in full. So, it is due on May 4, in two weeks instead of next week on May 11. There may be a test that day. So you may want to get to work on it now instead of waiting. What I covered in class enables you to do that. Also, there are differences between editions of the textbook. The assignment refers you to the book's Problem 9.1 on page 426, but in the current edition it has been renumbered as Problem 9.2, and is now on page 427. (4/22)

Demonstration programs for unix process mechanism "fork/exec" - If you wish to examine or experiment, here is the series of 11 programs used in my slides demonstrating the workings of fork and exec. You can get them by anonymous ftp from sputnik.smc.edu under the same names by which they appear in the slides shown in class: fork1.c, fork2.c,..., fork11.c. (Files are in /home/public/molay/ch08/, get them as outlined in the post entitled "Distributing files to you from sputnik". Slides are at links, lower left, entitled "Processes" and "Homemade shell". If you download these source files and want to compile so you can run them, the command to compile would be, for example:

  gcc  fork1.c  -o  fork1

The summary of the point of these programs is:

Version Purpose
fork1 shows fork, demonstrates that 2 processes result
fork2 shows PIDs (process id numbers) of these processes, and that they're distinct
fork3 shows fork's return value to the child copy (zero) and its return value to the parent copy (child's PID)
fork4 shows how to code differentiated behavior via an "if" structure conditioned on fork's return value
fork5 incorporates an exec call in the child
fork6 introduces exit call in child and wait call in parent, to give orderly discipline to their relative timing
fork7 gets the name of the program to be exec'd from the user via the command line
fork8 interactively gets the name of the program to be exec'd by prompting user
fork9 puts the activity inside a loop to extend it to second, third, fourth,... commands
fork10 shows a zombie process
fork11 shows an adopted child, init process as its step-parent after being pre-deceased by its original parent

(4/20)

Grades - up-to-date, at the link entitled "Grade information," at left. Please check your grades and call any anomalies to my attention. (4/20)

Upcoming topic - processes
read - textbook chapters we will cover on the topic of processes. Those are chapters 3 and 9 (process scheduling). You don't need to read much of chapter 9, just enough to enable assignment 9.
anticipate - assgt 9, to be done later, after I have demonstrated how to do it in class. (4/6)

Waste time in class - see in-class exercise link, lower right, entitled "waste time" (4/6)

Time sharing - a way to allow multiple interactive processes to share a computer's CPU pioneered by Fernando Corbato at MIT. (4/6)

Test help - below is a post I made here last year. It is about what I will talk about in class tonight. When the time comes to have a test (not yet), a parallel question will be on it:

...test will contain a problem that parallels an in-class demonstration I did. It concerned the textbook's Figure 1.5 "Program Flow of Control without and with Interrupts." I assigned time units to the various portions of the program shown in the Figure, both the 5 numbered ones and the I/O Command. Then I calculated the elapsed time from the start of the program till the time it finishes. I did that twice, once where interrupts are not used (Figure's left panel (a) ) and once where they are used (Figure's center panel (b) ). I assigned/posited the following amounts of time:
 1 - takes 6 units
 2 - takes 20 units
 3 - takes 18 units
 4 - takes 4 units
 5 - takes 4 units
 I/O command - takes 8 units

If that were the case, I reached the conclusion that the program as a whole would take 76 time units to complete if all phases ran consecutively (i.e., without interrupts) in the order shown in the Figure, versus only 60 time units if some phases ran concurrently (i.e., with interrupts). The test question is to perform the identical analysis/calculation, but with different input numbers supplied. Be sure you can do this problem, and you'll be able to do its companion problem on the test. (3/30)

Operation of a stack - to keep track of where to return after a function call. Shown in the gdb debugger (same one used by ddd debugger you used). (3/23)

Grades - updated. (3/23)

Homework
do - assignment at the link entitled "Assgt. 1.5b" in the column at right. Turn in on paper 3/23.
----------------
Some helpful explanation - here is how to correspond or reconcile the vocabulary in the textbook problem, and that at the end of my related writeup. There are 3 terms involved. What he calls T
m, I call Tslow. What he calls Tc, I call Tfast. What he calls "effective access time, I call Tave. There is no difference between what he and I are talking about, it's the same situation. The first term is talking about the native access time of one type of manufactured physical memory, and the second term about that of another. The second one is superior, does its job (moving data in and out) faster, costs more no doubt. Engineers buy that to make their caches. They buy the first, slower kind to make their RAM memory modules (regular memory) that you stick into the slots on your motherboard. The third term, on the other hand, is a little different in that it isn't talking about the native access time of anything. Rather, it's talking about the access time that would be experienced in actually using the computer. That doesn't match the native access time of either of the 2 memory types that the computer contains, since the computer uses a blend of both so that the experienced access time will fall somewhere in between their native times. Better than the slow one, not as good as the fast one. But in doing the problem just recognize that

 Tm = = Tslow

 Tc = = Tfast

 effective access time = = Tave

----------------
do - assgt 3.5, an assembly language program. due on sputnik by end-of-day Sunday March 25
read - chapter 2, "Operating System Overview." Specifically, the section entitled "The Operating System as Resource Manager" through the one entitled "Multicore OS Considerations." Optionally read the sections at the end specific to Windows and UNIX and how they implement the chapter's concepts. (3/16)

Grades - published, at the link entitled "Grade information," at left, including the in-class 3+2 exercise we did tonight. (3/9)

A discussion of hardware interrupts by Steve Gibson from his online podcast series "Security Now." Please listen if interested (28 min. duration) (3/9)

Homework - due Friday 3/16 on paper
do - assignment at the link entitled "Assgt. 1.5a" in the column at right.
----------------
Some helpful explanation - I didn't have time to comment on the assignment in class Friday. It is the author's 1.1 at the end of the chapter. It is very similar to the one in the book in Figure 1.4 (and the matching assembly language in-class exercise we did). The difference is, he wants to get/ put numbers from/to some devices, instead of memory. So, he gives you 2 new instructions (to go with the 3 you already know) in his hypothetical machine language, for the purpose of shuttling data back and forth to devices.  The instructions require id's of some kind for devices (just as memory locations require addresses, which serve as their id's). The author doesn't provide id's for the devices, but you can do so. You can make up your own id format and system. A good choice for this academic exercise might be 3-digit numbers such as 001 for device 1, 002 for device 2, and so on. Then, putting together the drawing I ask for is a matter of showing the devices and their contained values, and constructing a drawing pretty much the same as the one in Figure 1.4.)
----------------

read - selections from the "IA-32 Intel Architecture Software Developer's Manual, Volume 1: Basic Architecture."
 pp3-13 to 3-15 about registers in the Pentium
 pp3-20 to 3-22 about the EFLAGS status register
 p 3-24 about the EIP instruction pointer register
 p 3-26 about operands
 p 3-33 secion 3.7.7 "I/O Port Addressing." This relates to assignment 1.5a wherein you are asked to consider directing code to an I/O device (e.g., disk) as opposed to memory for data source and destination.
 pp 5-2 to 5-9 about general-purpose instructions, described and listed
read - the overview of interrupts at the very beginning of this article
read - this short page about interrupts. Click and read the link "Why Interrupts Are Used to Process Information." (3/9)

Grades - published, at the link entitled "Grade information," at left. Please check your grades and call any anomalies to my attention. (3/9)

First personal computer - Altair by Ed Roberts

(click photo to enlarge, note switches and lights on front panel)
(3/9)

No class meeting Friday night March 2 - I learned Santa Monica College has canceled all classes March 2, so our class won't meet that night. See you March 9. (2/28)

Dropped from class - Hernandez, Lorence (contact me if you want to reinstate). (2/24)

Homework - due electronically on sputnik end-of-day Saturday 3/3
do - assignment at the link entitled "Assgt. 2.5" in the column at right. It consists of some addition problems to do in the binary and hexadecimal number systems. Submit your answers to the questions following these preparation and submittal instructions (you will use scp/sftp to deposit your answer file in your "assignments" subdirectory on sputnik). Please name your file "sums.txt". I will grade these using an automated script, so the format of the answer is critical to intelligibility, as is the case (lower) of the filename.
anticipate - from assignment 1.5, the book's problem 1.1 at the end of Chapter 1, by reviewing the instruction execution example in Figure 1-4 of the textbook and associated discussion. Will be assigned soon. (2/24)

Adding 3 plus 2 in real life - look at Figure 1.4 in the William Stallings text book. It exemplifies a machine language program that adds 3 plus 2. I wrote such a program myself to do exactly that, in order to embody the Figure in real life. See the in-class exercise at the link entitled "3+2=5" below right. We'll be doing this exercise in class shortly. (2/24)

Linux intallations on B259 classroom computers - how do you use them?
From a cold start:
- turn on power
- press F12 while Dell logo shows on the screen
- from resulting menu, choose option for "Onboard SATA hard drive"
- another menu appears, from which choose Fedora (as opposed to Windows 7)
- a third menu appears, from which choose Fedora (as opposed to Restart)
- Fedora linux boots to a "login:" prompt

- log in as either "student" or as "root"
- get networking going (i.e., acquire an IP address) with command:
   dhclient  -v  eth1, if you are root, or
   su -c "dhclient  -v  eth1", if you are student (and give root's password when asked)
- to get a graphical interface (desktop) give command:  "startx &" (2/24)

Tutors wanted - by the computer department at SMC. We've been asked to suggest "knowledgdable students." I don't feel comfortable representing your exact offerings to the department, or the department's exact needs to you. Please be aware there is a need and contact the department if you think useful. (2/21)

Link to text's 7th edition website posted at left. (2/20)

PCBSD installation finished on the laptop shortly after class ended last night. I'll probably be able to bring in the laptop next week and show the outcome briefly. I found a link to a related YouTube video through PCBSD's website. (2/18)

Homework - please
 read chapter 1 of the textbook
 read the 7 links about binary and other number systems, below left, under the heading "Number bases" in the "Foundation Concepts" section.

read - write-up at link entitled "Remote Unix access with ssh" at left, and then:
log in - to your remote unix account. Please see section here entitled "Remote Unix system account for you". I will see your login history and record a minor grade credit for your having logged in. Log in by next week. After logging in, get out by running the "exit" command.

listen - to this podcast about operating systems (skip the part from the 6:00 minute mark to the 39:00 minute mark). It spans a lot of topics that we'll encounter in coming weeks, in a broad summary touching on all the items on the OS's job description list (the ones in paragraph titiled "Jobs" below). You won't understand some of it, and I considered not asking you to listen to it on the grounds that it bites off more than you can chew. But that's what the coming weeks are for. Listen to it now. Then, it would be interesting if you did so again after the course to see if I taught you anything.

anticipate, from assignment 1.5, the book's problem 1.1 at the end of Chapter 1, by reviewing the instruction execution example in Figure 1-4 of the textbook and associated discussion. (2/17)

Jobs for which operating systems have responsiblity:
 Internal
  memory management
  process management
  device management
  file management
 External
  user interface
 (2/18)

Slides we're viewing
 "Ch1 Computer Overview" - about interrupts, caching, etc
 "OS Installation" - about partitions, MBR, boot process, filesystems etc  (2/17)

Listed homework assignments at right - will not necessarily all be assigned. So don't go off and try to do them all on that erroneous assumption. They will be assigned selectively and explicitly. (2/18)

Textbook - Operating Systems: Internals and Design Principles, sixth edition, William Stallings, Pearson Prentice Hall. It appears to be offered in an online format. (2/17)

Requests  
- please don't change the root account passwords on the lab computers, as other classes use them.
- please turn the computers off at the end of class. I make the rounds and do it but it would be helpful if you turned off your own machines. In linux, "poweroff" at a command prompt does the job. (2/17)

Foundation concepts you should be(come) familiar with as background/prerequisite for this class:
 Data structures (lists, stacks)
 Binary and hexadecimal number representation
 Compiling/linking/loading (symbols, address fixups)
 ASCII code
 Processor instruction sets
 System architectures (bus, data lines, interrupt lines)
 Use of ssh
 Use of ftp/sftp (2/17)

Remote Unix system account for you
Your username - your last name as it appears on my class list, all lowercase. Duplicate last names were resolved by appending as many letters of the first names as needed to "break the tie." So if your lowercase last name doesn't work, add your first initial to it.
Your password - is 5 digits extracted from your phone number. If your phone number is 123-456-9876, then your password will be 56987 (final 2 digits from the 3-digit exchange, plus first 3 digits of the 4-digit number).
The target computer - is sputnik.smc.edu
Usage method - you will use it by independent methods for two independent purposes:
 - to log in to it remotely, obtaining a shell and conducting a usage session
 - to transfer files back and forth between it and the computer you are using locally
Students sometimes confuse these 2 different access methods and purposes.
To log in, use ssh as described in the "Remote Unix access with ssh" link at left. Accordingly if your name is John Smith for example, and you are using a command-line ssh client:

  ssh  smith@sputnik.smc.edu

and give your password when then prompted.
To transfer files, use any graphical ftp client that also supports sftp, and point it to sputnik.smc.edu. A good free graphical multi-platform client is filezilla. Alternatively use sftp and/or scp. They are command-line file transfer components of the ssh program. They are built-in to Filezilla, see this youtube tutorial. sftp and scp could also be used on the command line in OpenSSH/linux, or as "pscp" and "psftp" as part of PuTTY. When you perform an ftp or sftp login, you will be in a private directory on the remote sputnik computer. Each student has his own. It would be named /home/smith for our hypothetical friend John Smith. There, you'll see a subdirectory named "assignments." I will ask you to transfer homework files into that directory as the means of submitting them. (2/24)

Distributing files to you from sputnik - for that purpose, there is a user account on sputnik named "public". Its password is as given in class (email me a request if you don't remember). It contains a lot of files. You can download them using sftp/scp with those account credentials. (You may be familiar with anonymous ftp. This is comparable to it, however ssh/sftp/scp have no "anonymous" feature so this is a functionally similar workaround. Unlike your own home directory, you can only download from public's home directory, not upload.) I will from time to time ask you to acquire files from this source. 

To get a file I've placed in the home directory of user account "public" you might use scp/sftp from the linux command line, or Filezilla (on linux, Windows, or Mac) which is just a front end to the same thing as scp/sftp. If you use Filezilla, prefix the name of the target "Host" with "sftp://" or put a "22" in the "Port" field. This causes Filezilla to use sftp (the secure ftp that is part of ssh) rather than the regular, older, unsecure/unencrypted ftp protocol which it would use by default.

If you used scp to get a file named "softwaresecurity.zip" it would be done like this:

 scp  public@sputnik.smc.edu:/home/public/softwaresecurity.zip  . (don't omit the dot)

You would be prompted for the password of user account public, and would supply it. The file would transfer and you would find it sitting in your current directory (the dot is shorthand for "my current directory"). (4/27)

 

Eniac - 1946

Milestone in the history of computation

Assignments/due

Assgt. 1 telnet

Assgt 1.5a textbook

Assgt 1.5b textbook

Assgt. 2  ftp

Assgt 2.5 add

Assgt. 3 cmds

Assgt 3.5 assembly

Assgt. 4
session capture

Assgt 5 linux mem

Assgt 6 memseg

Assgt 7 pageaddr

Assgt 8 pagerepl

Assgt 9 scheduling

Assgt 10 filesystem


In-class exercises

line termination

3+2=5

waste time

process scheduling

MBR dump

Virtual memory swap

Operation of threads