1 / 27

CS120: Lecture 6

CS120: Lecture 6. MP Johnson Hunter mpjohnson@gmail.com. Agenda. Review OSs: History/motiv Duties Multiple processes Modern history - Stephenson. Program exec: add. Machines  OS. Can now write programs Complex programs still very difficult I/O, mem management, etc.

murray
Download Presentation

CS120: Lecture 6

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS120: Lecture 6 MP Johnson Hunter mpjohnson@gmail.com

  2. Agenda • Review • OSs: • History/motiv • Duties • Multiple processes • Modern history - Stephenson

  3. Program exec: add

  4. Machines  OS • Can now write programs • Complex programs still very difficult • I/O, mem management, etc. • Need an operating system

  5. OSs • Stephenson: “An OS … was a very long string of ones and zeroes that, when properly installed and coddled, gave you the ability to manipulate other very long strings of ones and zeroes.” • OS = prog / set or progs that • Manages computer, files • Helps you run programs

  6. Software taxonomy

  7. OS parts, tasks • Shell: provide access • Command-line, GUI (window manager) • Give access to files • Kernel: system housekeeping • Booting • Mem manage • Security • Comm with device drivers • Process management

  8. Booting • Starting up the comp, so programs can run • Last time saw: • Can run prog, once instructions are in RAM • Another prog could write them to RAM • …but who runs that prog? • Prob: for every running prog, some other prog must have run it

  9. Booting • Short for “bootstrapping” • Legend: German nobleman Baron Münchhausen lifted himself out of a swamp, by pulling his own hair • Later version: pulled seft out of the sea, but pulling his boot straps

  10. Booting • Soln: small prog (“bootstrap”) stored in ROM memory • At system startup, PC points to bootstrap • When it runs, it copies OS into RAM • And points PC there (JUMP) • Now OS can take over… • And load/run other programs • Another analogy: throw bundle of roap

  11. Booting • Depending on ROM/BIOS, many machines look for floppy/CD/USB • Try to boot from there • People install Linux on USB flash or iPod • Boot from that • Can also “dual-boot” • Bootstrap asks users which OS

  12. Mem manage • Saw that PC points to mem location • Each program has own space • OS prevents from reading/writing other program’s data • Prob: may not have enough RAM to hold all programs user runs • Soln: virtual memory • Redirect RAM request to HD • Slow…

  13. Security • Commonest idea: login • Prompt for user/pass • In Win, press ctr-alt-del to login (why?) • Finer-grain: • Read/write permissions for each file/dir • Some programs can’t write to HD • Java applets, ActiveX • Should they be able to listen on mic? Slashdot

  14. Device drivers • Main OS talks to device drivers • They talk to device controllers, • Which talk to device • General msgs sent from OS become more explicit • OS doesn’t need to know about your partic printer • It just needs the right device driver • Abstraction Win x65

  15. OS motiv • In old days: each program run indy • User writes prog, waits in line, runs, leaves • First change: separate user, machine • All programs given to computer operator, run by him, results given back • Next change: get all jobs, run as group • “batch processing” • Job described in JCL (job control lang) • Fast, automatic • But: if some bug, must start over from start

  16. OS motiv •  interactive programming/apps • Command-line or GUI • Convenient for user • But slow: wasted time while waiting for user input • Not everyone gets a mainframe • So other programs wait longer in line • Soln: time-sharing (user jobs) / multitasking (processes) • one of major tasks of modern OS

  17. Multiple processes • Process/job/thread = single program running • Process state: • Vals regs • Vals in (its) RAM • Program counter val • Process != program • Could have two instances of one prog running • E.g., dbl-click on Notepad twice

  18. Multiple processes • Very common: • Clock prog ticks • Doc prints • Browser loads • Playing game • NT has >100 processes, before you run anything • Some machines have mult processors • “dual-core” • But usually >> processes running • Can’t simply assign 1 to each processor •  time-sharing

  19. Time-sharing • Keep track of running processes in process table • Vars for each process • Where it’s at • Divide time into time-slices • E.g., 50 ms • At end of timeslice, have interrupt • Store info for curr proc in P.T. • Restart another process from where left off

  20. Time-sharing • Has some overhead • Memory of P.T. • Time to switch • But overall saves time • Better uses time when waiting for user • Modern OSs have “preemtive multitasking” • In Win 95/3.1, OS less strict about interrupting •  often hung

  21. Mult. procs  compet for resources • What if 2 progs want to print/draw/read at same time? • Only 1 can have access at once, or else conflict •  OS must control access how? • Simple idea: use a flag • 1/0, set/clear, says whether printer in use • On req, if clear, allow and set; o.w., make wait • When done, set clear, or give to waiting prog

  22. Flags • Countereg: • Prog1 requests prn • Check: clear, so…INTERUPT…set and given • Prog2 requests prn • Check: clear so…INTERUPT…set and given X • Soln: make check-and-set a single op • “semaphore”

  23. Spooling • Related is spooling • Won’t discuss strategies, but idea is: • When app wants to send job to device, take it, keep in buffer until device is ready • Common e.g.: print spooler

  24. Deadlock • Very serious problem • Two processes both waiting for resources, • Both dependent on other • Both “block” each other • P1: wants to upload from HD to netw card • Has HD access, waiting for netw access • P2: wants to download from new to HD • Has netw access, waiting for HD access •  deadlock!

  25. Dining philosophers (Dijkstra) • 5 philosophers eating sushi, around table • 5 chopsticks between them • To eat, phil must pick up two adjacent chopsticks, one at time • Sets them down after each bite • Goal: give strategy avoiding • Deadlock and • Starvation (of any phil)

  26. Modern OS history • Unix AT&T early 1970s • Apple II CLI late 70s • QDOS Tim Patterson early 80s • Purchase by Bill Gates for $50k  • MS-DOS 1982 • MacOS Apple 1984 • Win3.0 MS 1990 • Linux Linus Torvalds 1991 • NT MS 1993 • Win95 MS 1995 • x64 MS 2005

  27. Stephenson… • hw • For next time: read ch 4

More Related