COSC243 Part 2: Operating Systems - Department of Computer ... COSC243 Part 2: Operating Systems

download COSC243 Part 2: Operating Systems - Department of Computer ... COSC243 Part 2: Operating Systems

of 29

  • date post

    27-Jul-2018
  • Category

    Documents

  • view

    212
  • download

    0

Embed Size (px)

Transcript of COSC243 Part 2: Operating Systems - Department of Computer ... COSC243 Part 2: Operating Systems

  • COSC243 Part 2: Operating SystemsLecture 14: Introduction, and history of operating systems

    Zhiyi Huang

    Dept. of Computer Science, University of Otago

    Zhiyi Huang (Otago) COSC243 Lecture 14 1 / 27

  • General info

    Lecturer:Zhiyi HuangOffice 126, Owheo BuildingEmail: hzy@cs.otago.ac.nzTel: 479 5680.Teaching fellow: IainOffice G37A, Owheo BuildingEmail: ihewson@cs.otago.ac.nzTel: 479 8584.Textbook:Operating System Concepts with Java(8th Edition)A. Silberschatz, J. Galvin and G. Gagne.John Wiley (2009)

    Zhiyi Huang (Otago) COSC243 Lecture 14 2 / 27

  • Lectures

    Will use a small teaching OS xv6 to explain concepts:https://github.com/zhiyihuang/xv6_rpi2_portParticipate, think, criticize, learn!Not all material can be covered in lectures. You are expected to do12hrs/wk for this course, leaving 6hrs for readings andassignments.Any readings are examinable!A copy of the lecture notes will be available on the coursewebpage before each lecture.

    Zhiyi Huang (Otago) COSC243 Lecture 14 3 / 27

  • Tutorials and internal assessment

    Tutorials are an integral part of the course.The tutorial for each lecture will be available on the coursewebpage before each tutorial.Each tutorial is worth 0.5%. This mark is awarded for

    A quiz at the beginning of the tutorial;Participation in the rest of the tutorial.

    Summary of internal assessment:Tutorial marks: 10% in total.Data representation test in Tutorial 3A: 10%.CPU scheduling test in Tutorial 11A: 10%.Total: 30%.

    Zhiyi Huang (Otago) COSC243 Lecture 14 4 / 27

  • COSC243 Course overview

    Introduction (1 lecture): Ch1(1-8)Process Management (5 lectures)

    System Structure and Processes: Ch2(1-9),Ch3(1-2)Threads and data sharing: Ch4(1-4)Scheduling: Ch5(1-3,7)Synchronisation: Ch6(1-7)Deadlocks: Ch7

    Memory Management (2 lectures)Main memory: Ch8(1-6)Virtual memory: Ch9(1-7)

    File System Interface (1 lecture): Ch10(1-5),Ch11(1-4)I/O Management (2 lectures)

    I/O systems: Ch13(1-4,7)Mass storage: Ch12(1-4)

    Zhiyi Huang (Otago) COSC243 Lecture 14 5 / 27

  • Learning about Operating Systems

    Knowing about Operating Systems will change the way you workwith a computer.

    Knowing about low-level architecture issues doesnt make a bigimpact on how you use a computer day-to-day. But knowing aboutoperating systems does.

    Getting to grips with terminology. . .Some gobbledegook:

    One multi-threaded process uses fewer resources thanmultiple redundant processes, including memory, open files,and CPU scheduling. For example, as Solaris evolves,network daemons are being rewritten as kernel threads, toincrease greatly the performance of those network serverfunctions.

    (From an earlier edition of Silberschatz et al.)

    Zhiyi Huang (Otago) COSC243 Lecture 14 6 / 27

  • What is an Operating System?

    Defn 1: (protected intermediary) an operating system is a programwhich acts as an intermediary between the hardware and the user.

    What Andrew was

    user nuser 2user 1 . . . .

    computerhardware

    OPERATING SYSTEM

    system and application programs

    text editor databaseprogram

    compiler

    What Ill betalking about. talking about.

    An operating system makes life more convenient for the user, becauseshe doesnt have to operate at the level of machine instructions.

    Zhiyi Huang (Otago) COSC243 Lecture 14 7 / 27

  • What is an Operating System?

    Defn 2: (resource manager) an operating system is a program thatcontrols all of the systems resources, and decides how these are to beallocated.

    The resources of a computer system include. . .CPU TIMEMEMORY /STORAGECONTROL OF I/O DEVICES

    One role of an operating system is to improve the efficiency with whichthe computers resources are used, if theres heavy demand on them.

    Zhiyi Huang (Otago) COSC243 Lecture 14 8 / 27

  • What is an Operating System?

    Defn 3: (OS kernel) an operating system is a program which is alwaysrunning on a machine while it is in operation.

    When the machine is started up, a bootstrap program is run, toinitialise various things, and then the OS kernel is loaded andexecuted.The OS kernel is the code running with the highest privilege in themachine, accessing hardware directly and handling servicerequest (aka system calls) from user applications.The OS kernel basically cycles waiting for events to occur, e.g.interrupts or system calls at the background, but at the foregroundscheduling processes in a loop.

    Zhiyi Huang (Otago) COSC243 Lecture 14 9 / 27

  • Kernel Space and User Space

    Kernel space is the protected space where software has theprivilege to access any hardware.User space is the non-privileged space where software cannotaccess hardware directly unless permitted otherwise by the OSkernel.The OS kernel is run in the kernel space, while all other softwareare run in the user space.The CPU can tell if the software is run in the kernel space or theuser space by just checking one bit in its status word.OS kernel changes the bit when it switches to non-privilegedsoftware.When an interrupt or system call occurs, the bit is set to kernelspace.

    Zhiyi Huang (Otago) COSC243 Lecture 14 10 / 27

  • What is an Operating System?

    Defn 4: (different OS designs) an operating system is MS-DOS,Windows98, UNIX, MacOS, etc.

    This isnt just a kernel program; it also includes a whole set ofapplication programs that are compatible with this kernel and aretypically used in a particular environment.

    This is a colloquial use of the word operating system, and we wont beusing it.

    Zhiyi Huang (Otago) COSC243 Lecture 14 11 / 27

  • What is an Operating System?

    Heres the definition which well use to structure the course:

    Defn 5: an operating system is a program that manages the differentaspects of the operation of the machine and runs with the highestprivilege in a protected domain.

    Manages processes running on the machine.Manages data storage like RAM and file systems on the machine.Manages input/output devices associated with the machine.Manages networks and communications with other machines.Manages the user interface.Manages security and protection issues.

    Zhiyi Huang (Otago) COSC243 Lecture 14 12 / 27

  • Process Management

    Defn: a Process is a program in execution.

    A program is not a process! A program in execution is.Process management involves:

    creating and deleting processesscheduling processessuspending and resuming processesprocess synchronisationprocess communicationdeadlock handling

    Zhiyi Huang (Otago) COSC243 Lecture 14 13 / 27

  • Storage Management

    The term storage covers primary storage (main memory),secondary storage (hard disk), tertiary storage (floppy disks,tapes, CDs).Storage management involves:

    Allocating and deallocating storageKeeping track of storage in use and free storageTransferring data between primary and secondary storage

    Defn: the file system is the mechanism by which the useraccesses/manipulates stored data in secondary storage like hard disk.

    Zhiyi Huang (Otago) COSC243 Lecture 14 14 / 27

  • I/O Device Management

    A computer system can include a very wide range of I/O devices:keyboards, mice, printers, hard disks, CD-roms, etc etc etc.

    I/O device management includes tasks like:tracking the status of each deviceallocating devices to particular processesdeallocating devicesscheduling tasks for individual devices (e.g. disk scheduling)these functions are built into modules called device drivers; eachdevice needs one device driver to manage the hardware andserve the requests from user applications via the OS kernel.

    Note: we are not going to cover networks much in this paper.

    Zhiyi Huang (Otago) COSC243 Lecture 14 15 / 27

  • User Interface

    Defn: the shell is the program through which the user interacts withthe operating system.

    Two common types of shell:Icon-based point-and-click system (e.g. MacOS, MS Windows)Simple to learn and use.Keyboard-entered commands (e.g. UNIX)Harder to learn, but more powerful and flexible.

    The shell is (obviously) the aspect of an operating system which ismost evident to the user. But in fact its only a very small part of it.

    Note: we are not going to cover security much in this paper.

    Zhiyi Huang (Otago) COSC243 Lecture 14 16 / 27

  • The first computer system (1945)

    Zhiyi Huang (Otago) COSC243 Lecture 14 17 / 27

  • The first computer system

    The first computers didnt have operating systems:there was no intermediary system between the programmer andthe hardwarethe programmer gave instructions directly to the CPU.

    However, this meant that the CPU was idle for most of the time.

    Zhiyi Huang (Otago) COSC243 Lecture 14 18 / 27

  • Batch operating systems

    The first operating systems were introduced to increase the efficiencyof (I/O) processes.

    Programmers didnt deal directly with these machines: instead,they prepared their programs as jobs, and submitted their jobs tooperators. It wasnt possible to interact with a program while it wasexecuting.Operators grouped jobs together and submitted batches of jobs tothe machine. The computer then needed an operating system totransfer control automatically from one job to another.

    These early batch operating systems were still inefficient:I/O processing is still very slow in comparison to CPU processing;While I/O is occurring, the CPU is still idle.

    Zhiyi Huang (Otago) COSC243 Lecture 14 19 / 27

  • Spooling (Simultaneous Peripheral Operations OnLine)

    A solution to the I/O bottleneck is to perform I/O for one job J1 at thesame time as the CPU is executin