Operating Systems

Operating Systems

Outline • Introduction Operating Systems • Process management • Interrupts TDTS10 • Memory management • File system • Device drivers Erik Larsson • Networking (TCP/IP, UDP) Department of Computer Science • Security (Process/Memory protection) • I/O 2 Outline Outline • An Operating System (OS) is software • For hardware functions such as input (program) running on the computer and output and memory allocation, the (hardware) OS acts as an intermediary between application programs and the • The objective of the OS is to: computer hardware • manage the hardware resources of the computer system, and • The application code (software) is usually executed directly by the • provide services for the execution of application software. hardware (computer) but will frequently call the OS or be • Almost any system that contains a interrupted by it. computer has an OS—from cellular phones and video game consoles to • Note: an OS is not needed to execute supercomputers and web servers. a program. Some game consoles runs directly on the hardware. 3 4 Examples UNIX • UNIX • Ken Thompson and Dennis M. Ritchie • Windows • Turing award (“Nobel prize for • Other computer science”), 1983 • For their development of generic operating systems theory and specifically for the implementation of the UNIX operating system • Also • Ken Thompson developed C at Bell Labs and Go at Google Inc. • Dennis M. Ritchie developed C at Bell Labs 5 6 UNIX Linux • Linus Benedict Torvalds, born 1969, Finland • Wanted to learn OS, developed an OS • Linus' Law: Given a large enough beta-tester and co-developer base, almost every problem will be characterized quickly and the fix will be obvious to someone. • (Edsger W. Dijkstra: Program testing can be used to show the presence of bugs, but never to show their absence!) 7 8 Windows 1 • MS-DOS (Microsoft Disk Operating System) (~1980) • Target: Single user on PC (X86-architectures), not network 2 connected • Effect: Low security • Windows 1.0 (1985) • Windows 95, 98, 2000, XP, Vista, 7, 8? 4 3 9 10 Windows Other • Digital Equipment Corporation (DEC): OpenVMS (Open Virtual Memory System • Microsoft/IBM: OS/2 • Enea: Enea OSE • Nokia: Symbian • Google: Android 11 12 What does the OS do? 1. Process management • Process management • Execute program is a main task of the OS • Interrupts • A program (SW) needs resources to execute • Memory management • Programs alter between CPU and I/O cycles • File system • To increase CPU utilization, multiprogramming (time sharing, • Device drivers multi-tasking) – letting more than one program active – is proposed • Networking (TCP/IP, UDP) • OS regains control of the processor during a program’s • Security (Process/Memory protection) execution: • I/O • The process issues a system call (sometimes called a software interrupt); for example, an I/O request occurs requesting to access a file on hard disk. • A hardware interrupt occurs; for example, a key was pressed on the keyboard, or a timer runs out (used in pre-emptive multitasking). 13 14 Process model Process model • Two-state (Running and Not Running) • The scheduler picks one process from the Not Running queue and let it execute on the CPU. At interrupt (for example at end of time slice), a context switch takes place and a new program is loaded to the CPU • Three-state (Running, Ready, Blocked) • A drawback of the two-state model is that the CPU stays idle when a process does I/O operations. A new state (Blocked) is introduced). • Five-state (Running, Ready, Blocked, Ready suspended, Blocked suspended) • To handle virtual memories (for example move a process from primary memory to secondary memory), more states are needed 15 16 Scheduler Scheduling • Long-term scheduler – decides which jobs can enter the ready • MS-DOS– non multi-task system; hence, no scheduler queue • Windows 3.1 - non-preemptive scheduler (did not interrupt • Mid-term scheduler – decides which jobs shall be in primary programs) (main) memory and which shall be in the secondary memory • Windows NT, Linux, MacOS - multilevel feedback queue, • Short-term scheduler – decides which job to execute at any time • Algorithms: • First In First Out • Shortest Job First • Priority based scheduling • Round-robin scheduling • Multilevel Queue scheduling 17 18 Program execution Context switch 19 20 Process control block 2. Interrupts • Process Control Block (PCB, also called Task Controlling Block • Interrupts are important to implement time-sharing OS or Task Struct): a data structure containing the information • An interrupt makes the processor: needed to manage a particular process. • Save its state • Typical content: • Execute interrupts handling sequence • The identifier of the process (a process identifier, or PID) • Interrupts • Register values for the process including, notably, the program counter and stack pointer values for the process. • Hardware interrupts • The address space for the process • Software interrupts • Priority • Process accounting information, such as when the process was last run, how much CPU time it has accumulated, etc. • I/O Information (i.e. I/O devices allocated to this process, list of Resource (hard disk, opened files, etc) printer, ….) 21 22 Timer Interrupt CPU 3. Memory management 4. File system • A multiprogramming operating system control the usage of the • How keep track on all bits? memory so that each program has its part and do not interfere • Typically, you cannot address an individual bit (overhead with other programs becomes too large). • Relocation • Files and directories • be able to relocate programs in memory and handle memory • Examples: File Allocation Table (FAT), New Technology File references and addresses in the code of the program so that they always point to the right location in memory System (NTFS) • Memory protection • processes should not be able to reference the memory for another process without permission • Sharing • sometime different processes need to be able to share information and therefore access the same part of memory 23 24 Inode 5. Device drivers • Device driver (software) interface with hardware, such as: • Printers, video adapters, network cards, sound cards, low- • Each file in Unix has an Inode bandwidth I/O buses of various sorts (for pointing devices such as • Example: mice, keyboards, USB, etc.), computer storage devices such as hard disk, CD-ROM and floppy disk buses (ATA, SATA, SCSI). • Twelve pointers that directly point to blocks of the file's data (direct pointers) • Execution: kernel-mode or user-mode (to be discussed soon)? • One singly indirect pointer (a pointer that points to a block of pointers that then point to blocks of the file's data) • One doubly indirect pointer (a pointer that points to a block of pointers that point to other blocks of pointers that then point to blocks of the file's data) • One triply indirect pointer (a pointer that points to a block of pointers that point to other blocks of pointers that point to other blocks of pointers that then point to blocks of the file's data) 25 26 6. Networking 7. Security • Communication media • Microsoft targeted single user systems with no network • Wired technologies connection; hence, security was not an issue • Twisted pair (telephone wire), coaxial cable (TV), optical fiber • UNIX targeted multi-user (multitasking); hence, designed in a • Wireless technologies more secure way • WLAN, Bluetooth • Communications protocol • Ethernet (IEEE 802) • Internet Protocol Suite (Transfer Control Protocol, is one of the core protocols of the Internet Protocol Suite (TCP/IP)) 27 28 8. Input/Output Rings • I/O is all communication with the outside of the computer • Rings is hardware support to give protection • Examples – keyboards, monitors, discs, printers • Typically two modes: user-mode and supervisor-mode • MS-DOS – only supervisor-mode • Windows, Linux – supervisor and user mode 29 30 Kernel Things to be handled….. • The kernel is the main component of the OS. It acts as the interface • Assume 10 equal study rooms in a library. To request one room, between programs (applications) students puts request at front counter. At front counter, a variable is and the hardware. decremented at requests and incremented when a room is free. If no room is free, students form a queue. • Microkernel or monolithic kernel (Tanenbaum–Torvalds debate) • Solutions must handle: • requesting a resource and forgetting to release it, • releasing a resource that was never requested, • holding a resource for a long time without needing it, or • using a resource without requesting it first. • Avoid: Deadlock/starvation • When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone (Law in Kansas) 31 32 Semaphores Atomic operations Semaphores (Edsger Dijkstra) • If S>0 then S=S-1 corresponds to: Two operations: 1. Read S V stands for verhogen ("increase”) 2. If S>0 then S=S-1 function V(semaphore S, integer I): 3. Write S [S ! S + I] • S is a common variable that can be read by anyone. One P stands for the portmanteau prolaag, short resource (S=0 or 1). for probeer te verlagen, literally "try to reduce” • S=1 (resource is free) function P(semaphore S, integer I): • Process A Process B repeat: [if S >= I: • Read S //S=1 S ! S – I • Context switch (A->B) break] • Read S //S=1 P and V must be atomic (test-and-set or turn of interrupt) 33 34 Problems Other problems • Five silent philosophers at a table do one • Cigarette smokers problem of two things: eating or thinking. While • Dining philosophers problem eating, two forks are needed and only forks next to a particular philosopher can • Readers-writers problem be used. • Sleeping barber problem • Problems: • Producers-consumers problem • Deadlock – example: if each philosopher picks left fork and then waits for right fork • Starvation – example: if a philosopher picks left fork and keeps it for no longer than five minutes 35 36 www.liu.se .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us