Chapter 1 Introduction March 2013 Jongmoo Choi Dept

  • Slides: 31
Download presentation
Chapter 1. Introduction March, 2013 Jongmoo Choi Dept. of software Dankook University http: //embedded.

Chapter 1. Introduction March, 2013 Jongmoo Choi Dept. of software Dankook University http: //embedded. dankook. ac. kr/~choijm J. Choi, DKU

Contents 1. 1 What Operating Systems Do 1. 2 Computer System Organization 1. 3

Contents 1. 1 What Operating Systems Do 1. 2 Computer System Organization 1. 3 Computer System Architecture 1. 4 Operating System Structure 1. 5 Operating System Operations 1. 6 Process Management 1. 7 Memory Management 1. 8 Storage Management 1. 9 Protection and Security 1. 10 Distributed Systems 1. 11 Special-Purpose Systems 1. 12 Computing Environments 1. 13 Open-Source Operating Systems 1. 14 Summary 2 J. Choi, DKU

Chapter Objectives To provide a grand tour of the major components of operating systems

Chapter Objectives To provide a grand tour of the major components of operating systems To describe the basic organization of computer systems 3 J. Choi, DKU

1. 1 What Operating Systems Do Abstract view of the components of a computer

1. 1 What Operating Systems Do Abstract view of the components of a computer system ü Four components: hardware, operating system, system/application programs, users (cf. three components without users) 4 J. Choi, DKU

1. 1 What Operating Systems Do Details of the Four components ü Hardware §

1. 1 What Operating Systems Do Details of the Four components ü Hardware § CPU, memory, I/O devices § Provides basic computing resources for the system ü Operating system § Controls and coordinates use of hardware resources among various application/system programs for users (managing hardware) and supporting computing environments to programs/users § Intermediary between programs/users and hardware ü System/Application programs § Word processors, compilers, web browsers, database systems, video games § Define the ways in which the system resources are used to solve users’ computing problems ü Users § People, machines, other computers 5 J. Choi, DKU

1. 1 What Operating Systems Do Goals ü ü Convenience and efficiency Others: Fairness,

1. 1 What Operating Systems Do Goals ü ü Convenience and efficiency Others: Fairness, Low power, Qo. S, Transparency, … User view about the role of operating systems ü ü ü PC: Ease to use Mainframe (minicomputer): Resource utilization Workstation and server: Balancing Handheld computer: Performance per battery Embedded computer: Autonomous (without user intervention) System View about the role of operating systems ü ü Resource manager (common accepted definition) Control program (similar to a government) F kernel: program running at all time on the computer 6 J. Choi, DKU

1. 2 Computer-System Organization A modern computer systems ü ü One or more CPUs,

1. 2 Computer-System Organization A modern computer systems ü ü One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices (interrupt, DMA) F resource manager: process(thread), virtual memory, file system, device driver, protocol, interrupt handler, initialization, … 7 J. Choi, DKU

1. 2 Computer-System Organization Initialization ü Power-on Bootstrap (a. k. a firmware) Kernel loading

1. 2 Computer-System Organization Initialization ü Power-on Bootstrap (a. k. a firmware) Kernel loading Init shell Interrupt ü Inform an occurrence of an event (either hardware or software) to OS § Hardware: sending a signal to the CPU through the system bus § Software: execute a special operation, called trap (or system call) ü Interrupt handling § Using vector table (locate in a fixed address, usually contain the start address of the corresponding interrupt handler) § Context save and restore 8 J. Choi, DKU

1. 2 Computer-System Organization Storage structure ü ü Storage systems organized in hierarchy. Speed

1. 2 Computer-System Organization Storage structure ü ü Storage systems organized in hierarchy. Speed vs. Cost vs. Capacity vs. Volatility 9 J. Choi, DKU

1. 2 Computer-System Organization Characteristics of Storage ü Main memory (volatile) § The place

1. 2 Computer-System Organization Characteristics of Storage ü Main memory (volatile) § The place where CPU can load instruction and data directly (byteaddressable), hence any programs to run must be located there, managed by virtual memory (cf. Von Neumann Architecture) § DRAM, SRAM, ROM, EEPROM, … § load/store: transfer between register and main memory (an array of words: address and content pairs) § Considerations: too small to contain all needed programs, volatile ü Secondary storage (non-volatile) § Extension of main memory, providing large nonvolatile storage capacity (sector-addressable), managed by file system and swapper. § Magnetic disks, Electronic disks (Flash memory, NVRAM, DRAM with battery backup). Optical disks, Tapes, . . . § read/write: transfer btw main memory and storage (also called load/store) § Considerations: relative slow, integrity, … F Caching: keeping data in faster layer (eg. main memory can be viewed as a cache for secondary storage, CPU cache as a cache for main memory, and J. so. Choi, on)DKU 10

1. 2 Computer-System Organization I/O structure ü Bus, Device Controller, Devices (Source: computer systems:

1. 2 Computer-System Organization I/O structure ü Bus, Device Controller, Devices (Source: computer systems: a programmer perspective) 11 J. Choi, DKU

1. 2 Computer-System Organization I/O structure ü Device driver § A portion of operating

1. 2 Computer-System Organization I/O structure ü Device driver § A portion of operating system that manages a device controller directly § Present a uniform interface ü Device controller (or device itself) § Maintain a set of special-purpose registers (control and status registers), logic and internal buffer § Some controller can manipulate multiple devices • eg. Seven or more devices can be attached to the SCSI (Small Computer System Interface) controller § Control transfer: Interrupt vs. Polling § Data transfer: Programmed I/O vs. DMA 12 J. Choi, DKU

1. 3 Computer-System Architecture Categories according to the number of processors ü Single processor

1. 3 Computer-System Architecture Categories according to the number of processors ü Single processor systems § Can have s set of special-purpose processors (eg. GPU, RAID controller) ü Multiprocessor systems § a. k. a. Tightly-coupled systems (or parallel system) § Advantages: 1) increased throughput, 2) economy of scale, 3) increased reliability (graceful degradation or fault tolerant), … § Two types based on symmetry • • Asymmetric multiprocessing: each processor is assigned a specific task (master/slave relationship). Symmetric multiprocessing (SMP): each processor can perform any tasks. most common, need OS supports (synchronization, load balancing, …) § Two types based on main memory • • UMA: Uniform Memory Access NUMA: Non-Uniform Memory Access § Recent trends: Multicore • • Multiprocessor in a single chip Faster and less power consumption 13 J. Choi, DKU

1. 3 Computer-System Architecture Categories according to the number of processors ü Clustered systems

1. 3 Computer-System Architecture Categories according to the number of processors ü Clustered systems § Composed of two or more computers (not just processors) • Eg. Beowulf clusters: PCs + LAN + Open-source software § High-Availability, High-performance, Bigdata processing, Cloud computing, … § Asymmetric or symmetric clustering § Parallel programming, SAN, DLM(Distributed Lock Manager), … (Symmetric multiprocessing vs. Clustered Systems) 14 J. Choi, DKU

1. 4 Operating-System Structure Single programming system ü Only one program in main memory

1. 4 Operating-System Structure Single programming system ü Only one program in main memory Multiprogramming system ü ü Multiple programs in main memory Job (process or task) switching occurs if a currently running job have to wait, such as an I/O operation Increase CPU utilization (and resource) Need memory management (virtual memory, swapping) Multitasking system ü ü ü Switching is also triggered after a time quantum Time-sharing system (preemptible) Increase interactivity (usually response time < 1 sec. ) Support multiple users simultaneously Need process and CPU scheduling 15 J. Choi, DKU

1. 4 Operating-System Structure Overall structure process 1 process 2 process 3 process n

1. 4 Operating-System Structure Overall structure process 1 process 2 process 3 process n User Space System Call Interface Filesystem Manager Ext 4 fs proc xiafs minix nfs msdos Process Manager Memory Management Task Management Scheduler Signaling Kernel Space Buffer Cache Device Driver block Network Manager character socket Ir. DA Console KBD SCSI CD-ROM PCI ethernet Ipv 6 Hardware Interface (Interrupt, DMA) dev 1 dev 2 dev 3 dev 4 devn (Source: Linux Kernel Internals) 16 J. Choi, DKU

1. 5 Operating-System Operations Dual mode ü Multiple programs and OS Need protection §

1. 5 Operating-System Operations Dual mode ü Multiple programs and OS Need protection § User mode, Kernel mode (or privileged, supervisor) : to distinguish btw the execution of OS code and user code § Use mode bit (eg. I/O Privilege bits in eflags register in Intel CPU) ü How to go into the kernel mode: through interrupt § Hardware interrupt: Devices, Timer (time-sharing), … § Trap (or exception): system call, error(division by zero, invalid memory access), … ü More details in Chapter 2 User mode Kernel mode 17 J. Choi, DKU

1. 6 Process Management Key Terminologies ü Process § § ü A program in

1. 6 Process Management Key Terminologies ü Process § § ü A program in execution (passive vs. active) Need resources: CPU, memory, files, I/O devices, … Manipulation: create, wait, exec, suspend, resume, terminate, … More details in Chapter 3 Thread § Lightweight process or Control flow (program counter) § More details in Chapter 4 ü Scheduling § Select a process who runs next § More details in Chapter 5 ü Synchronization § Process/thread coordination § More details in Chapters 6 and 7 18 J. Choi, DKU

1. 7 Memory Management Goal: Supporting multiple processes efficiently ü ü Keeping track of

1. 7 Memory Management Goal: Supporting multiple processes efficiently ü ü Keeping track of which parts of memory are currently being used and by whom (page, segmentation) Allocating and deallocating memory space as needed (Buddy) Deciding which processes (or part) and data to move into and out of memory (swapping, demand paging, replacement) More details on Chapters 8 and 9 19 J. Choi, DKU

1. 8 Storage Management Key abstraction: File ü ü ü A uniform, logical view

1. 8 Storage Management Key abstraction: File ü ü ü A uniform, logical view of information storage For convenience of users Hiding physical complexities (handled by drivers or controllers) File system ü ü ü Creating and deleting files Managing directories to organize files Primitives to manipulate files and directories such as access control Mapping files onto secondary storage More details on Chapters 10 and 11 20 J. Choi, DKU

1. 8 Storage Management Mass Storage Management ü ü ü Usually disks used to

1. 8 Storage Management Mass Storage Management ü ü ü Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time. Free-space management Storage allocation Disk Scheduling Several techniques to mitigate the notorious CPU/Disks gaps More details on Chapters 12 21 J. Choi, DKU

1. 8 Storage Management Caching ü ü Important principle of computer system to enhance

1. 8 Storage Management Caching ü ü Important principle of computer system to enhance efficiency with reasonable resources Assume two layers in hierarchy (named L 1, L 2 with size of S 1, S 2) § Access latency: L 1 case = T 1, L 2 case = T 1 + T 2 (for caching) § Hit ratio affects the average latency: T = h * T 1 + (1 -h) * (T 1 + T 2) • Eg. ) if (T 1 = 25, T 2 = 250, h = 0. 9), then T = 25*0. 9 + 275*0. 1 = 50 § Locality allows high hit ratio with reasonable cache size (≥ S 1/S 2) § More details in Chapter 9 and Chapter 11 C PU Storage Hierarchy L 1 L 2 22 J. Choi, DKU

1. 8 Storage Management Caching: no free lunch ü ü Utilized actively at various

1. 8 Storage Management Caching: no free lunch ü ü Utilized actively at various points in a computer (in hardware, operating system, database, …) Require consistency § Assume that an integer A located in a file B is incremented by 1 • • • ü From disk to main memory (by OS) From main memory to CPU cache (by hardware) From cache to a specific register (by compiler) Incremented by ALU Write back to CPU cache, main memory and disks (can be delayed) Require cache coherency (especially in SMP or distributed systems) § Between CPU caches (See figure in page 14) or Client caches § More details in Chapter 17 23 J. Choi, DKU

1. 8 Storage Management I/O Systems ü ü ü A lot of devices, Diversity

1. 8 Storage Management I/O Systems ü ü ü A lot of devices, Diversity One purpose of OS is to hide peculiarities of hardware devices from the user (abstract devices like a file) Roles § General device-driver interface (generic file interface) § Drivers for specific hardware devices § I/O Memory management including buffering (storing data temporarily while it is being transferred), caching (storing parts of data in faster storage for performance), spooling (the overlapping of output of one job with input of other jobs) § I/O Interrupt handling § More details in Chapter 13 24 J. Choi, DKU

1. 8 Storage Management I/O Systems ü Synchronous vs. Asynchronous I/O Synchronous Asynchronous 25

1. 8 Storage Management I/O Systems ü Synchronous vs. Asynchronous I/O Synchronous Asynchronous 25 J. Choi, DKU

1. 9 Protection and Security (Optional) Protection ü Any mechanisms for controlling access of

1. 9 Protection and Security (Optional) Protection ü Any mechanisms for controlling access of processes or users to resources defined by the OS § A process can execute only within its own address space § The timer ensures that no process can gain control of the CPU without eventually relinquishing control § Device-control registers are not accessible to users directly § Regulate users to access authorized files only ü More details in Chapter 14 Security ü ü ü Defense of the system against internal and external attacks Virus, worm, Do. S, identity theft, theft of service, … More details in Chapter 15 Protection/Security require User identities (User ID, Resource ID) ü ü ü Unique, one per user (or group) Associated with processes and files Privilege escalation (such as setuid bit) 26 J. Choi, DKU

1. 10 Distributed Systems (Optional) Distributed systems ü Definition § A collection of computer

1. 10 Distributed Systems (Optional) Distributed systems ü Definition § A collection of computer systems that are networked § To increase performance, functionalities, data availability, reliability § eg) FTP, NFS, Distributed DB, … ü Network § Protocol: TCP/IP, ATM, NFC, Sensor network, … § Distance: LAN, WAN, MAN, PAN, CAN, … ü Networked operating system § Provide file sharing, communication schemes, parallel processing, Distributed lock management, … § eg) NOW, Hadoop, . NET, … ü More details in Chapters 16~18 27 J. Choi, DKU

1. 11 Special-Purpose Systems (Optional) Real-time embedded systems ü ü Car engine, manufacturing robot,

1. 11 Special-Purpose Systems (Optional) Real-time embedded systems ü ü Car engine, manufacturing robot, microwave oven, home network, sensor, … Have specific tasks (usually limited) § Firmware based, Special OS based, General OS based, … ü ü Requirement: Real-time feature (deadline consideration) More details in Chapter 19 (partly in Chapters 5 and 9) Multimedia systems ü ü Multimedia data: audio, video files as well as conventional files Video conferencing, Web casting, Movie preview, … Requirement : Qo. S, Synchronization More details in Chapter 20 Handheld systems ü ü ü PDA, Smartphone, Pad, … Requirement: Low power, Resource limitation More and more popular (more market volume than PCs) 28 J. Choi, DKU

1. 12 Computing Environments Traditional computing ü Office environments § Standalone § PCs connected

1. 12 Computing Environments Traditional computing ü Office environments § Standalone § PCs connected to a network, Terminals attached to mainframes § Portal with web technology, network computers, wireless network ü Home environments § Single computer Multiple computers and handheld devices Client-Server computing ü Computing or File Servers Peer-to-Peer computing ü ü ü All nodes are considered peers May each act as client, server or both Protocol: Join, Register or Broadcast (Napster or Gnutella) Web-based computing ü Ubiquitous, Easy to use/provide (Standard) F As computing matures, the lines separating computing environments are blurring 29 J. Choi, DKU

1. 13 Open-Source Operating Systems Availability of source code ü Open-source (Linux, BSD, …)

1. 13 Open-Source Operating Systems Availability of source code ü Open-source (Linux, BSD, …) vs. Closed-source (Windows) § § ü ü ü www. kernel. org www. freebsd. org www. opensource. apple. com Opensolaris. org Issues: Reliable, profitable, manageable, … Learning operating systems by examining the actual code is extremely useful. GNU, FSF (Free Software Foundation) by R. Stallman 30 J. Choi, DKU

Summary Operating system definition ü ü Manage hardware resources Provide computing environment for programs

Summary Operating system definition ü ü Manage hardware resources Provide computing environment for programs to run Resources ü ü Physical: CPU, main memory, secondary storage, I/O devices, … Logical: Process/thread, virtual memory, file system, driver, protocol, security, distributed system, real-time, … Consideration ü ü ü ü Storage hierarchy, Caching SMP support, Scheduling Multiprogramming support Devices diversity Protection (dual mode) Web influence … 31 J. Choi, DKU