480 likes | 561 Views
Chapter 1 Introduction to Operating System. Bernard Chen Spring 2007. Outline. 1.1 What is OS 1.2 Computer System Organization 1.3 Computer System Architecture 1.4 OS Structure 1.5 OS Operations 1.6-1.8 Process, Memory, Storage management 1.9 Protection and Security 1.10~ Systems.
E N D
Chapter 1Introduction to Operating System Bernard Chen Spring 2007
Outline 1.1 What is OS 1.2 Computer System Organization 1.3 Computer System Architecture 1.4 OS Structure 1.5 OS Operations 1.6-1.8 Process, Memory, Storage management 1.9 Protection and Security 1.10~ Systems
1.1 What is Operating System? • An operating system is a program that manages the computer hardware. • It also provides a basis for application programs and acts as an intermediary between the computer user and computer hardware.
What do Operating System do? • The computer system can be divided roughly into four components: • The hardware • The operating system • The application software • The Users
USER View of OS • Ease to use (Home PCs) • Efficient resource utilization (Work stations)
SYSTEM view of OS • OS is a resource allocator Manages all resources (CPU time, memory space, storage space, I/O and so on) Decides between conflicting requests for efficient and fair resource use • OS is a control program Controls execution of programs to prevent errors and improper use of the computer
1.2 Computer System Organization • Basic Organization • Storage Structure • I/O structure
Computer Startup Bootstrap program is loaded at power up or reboot • Typically stored in ROM, generally known as firmware • Initialize all aspects of system • Loads operating system kernel and starts execution
1.2.1 Computer System Organization • I/O devices and the CPU can execute concurrently. • Each device controller is in charge of a particular device type. • Each device controller has a local buffer.
1.2.2 Storage Structure Main Memory: • Main memory is the only large storage media that the CPU can access directly • Main memory is usually too small to store all needed programs and data • Main memory is a volatile storage device that loses its contents when power is off
1.2.2 Storage Structure • Therefore, most computer provide secondary storage as extension to store web browser, compliers, word processors…etc
1.2.2 Storage Structure • Storage systems organized in hierarchy. Speed Cost Volatility • Caching–copying information into faster storage system; main memory can be viewed as a last cache for secondary storage.
Caching • Information in use copied from slower to faster storage temporarily • Important principle, performed at many levels in a computer (in hardware, operating system, software)
Caching • Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there • Cache is usually smaller than storage being cached • Cache management is an important design problem • Cache size and replacement policy
1.3 Computer-System Architecture • 1.3.1 Single-Processor Systems • 1.3.2 Multiprocessor Systems • 1.3.3 Cluster Systems
1.3.1 Single-Processor Systems • On a single processor system, there is only one main CPU capable of executing a general purpose instruction set. • Some other special-purpose processors may also included. Such as: GPU Disk-controller microprocessor Keyboard microprocessor
1.3.2 Multiprocessor Systems • Also called Parallel Systems • Advantages: • Increase throughput • Economy of scale • Increase reliability (fault tolerant)
1.3.2 Multiprocessor Systems • Two types of multiprocessor systems: 1. Asymmetric multiprocessing (master and slave processors) 2. Symmetric multiprocessing (Shared memory system)
1.3.3 Clustered Systems • Clustered computers share storage and are closely linked via Local-area network (LAN) or a faster interconnection.
1.4 OS Architecture One of the most important aspect of OS is the ability to Multiprogramming • Single user cannot keep CPU and I/O devices busy at all times • One job selected and run via job scheduling • When it has to wait (for I/O for example), OS switches to another job
Multiprogramming • Jobs are stored in “Job Pool” • Virtual memory is the useful technique for the limitation size of physical memory
1.5 OS operations • Interrupt (driven by hardware) vs. Trap (called by software or error) • Trap example: divide by 0; invalid memory access • We need to make sure that an error in a user program could cause problems only for the one program that was running (such as infinite loop)
Dual Mode Operation • Dual-mode operation allows OS to protect itself and other system components • It contains user mode (mode bit:1) and Kernel mode (mode bit:0) • The operating system loaded user application starts in user mode. Whenever a trap or interrupt occurs, hardware switches to kernel mode.
C library handling of write() #include<stdio.h> Int main() { … printf(“hellow world”); … } User mode Standard C library Kernel mode Write() system call
Dual Mode Operation • Privileged instructions: some machine instructions that may cause harm, can only be executed in kernel mode. • Such as instruction switch to user mode; I/O control; timer management, and interrupt management.
Timer To prevent the OS out of control by CPU • Set interrupt after specific period • Operating system decrements counter • When counter zero generate an interrupt • Set up before scheduling process to regain control or terminate program that exceeds allotted time
Process management • A process is a program in execution. It is a unit of work within the system. • Process needs resources to accomplish its task CPU, Memory, files, I/O devices • Process termination requires reclaim of any reusable resources
Process management • Single-threaded process has one program counter (PC) specifying location of next instruction to execute Process executes instructions sequentially, one at a time until completion • Multi-threaded process has one program counter per thread
Process management The operating system is responsible for the following activities in connection with process management: • Creating and deleting both user and system processes (Ch3) • Suspending and resuming processes (Ch5) • Providing mechanisms for process synchronization (Ch6) • Providing mechanisms for process communication (Ch4) • Providing mechanisms for deadlock handling(ch7)
Memory Management • All data in memory before and after processing • All instructions in memory in order to execute • Memory management determines what is in memory when optimizing CPU utilization and computer response to users
Memory management activities • Keeping track of which parts of memory are currently being used and by whom • Deciding which processes and data to move into and out of memory • Allocating and deallocating memory space as needed
Storage Management OS provides uniform, logical view of information storage • file • Each medium is controlled by device (i.e., disk drive, tape drive)
Storage Management File-System management • Files usually organized into directories • Access control on most systems to determine who can access what • OS activities include • Creating and deleting files and directories • Primitives to manipulate files and dirs • Mapping files onto secondary storage • Backup files onto stable (non-volatile) storage media
Mass 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. • OS activities • Free-space management • Storage allocation • Disk scheduling • Tertiary storage includes optical storage, magnetic tape • Varies between WORM (write-once, read-many-times) and RW (read-write)
Protection and Security • Protection–any mechanism for controlling access of processes or users to resources defined by the OS (Ch14) • Security–defense of the system against internal and external attacks even when protection is activated (Ch15) (including denial-of-service, worms, viruses, identity theft, theft of service)
Protection and Security Systems generally first distinguish among users, to determine who can do what • User identities (user IDs, security IDs) include name and associated number, one per user • User ID then associated with all files, processes of that user to determine access control • Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file • Privilege escalation allows user to change to effective ID with more rights
Computing Environments Traditional computer • Used to be single system, then modems • Now firewalled, networked
Client-Server computing • Many system now servers, responding request to clients
Peer Peer-to to-Peer Computing • Another model of distributed system • P2P does not distinguish clients and servers • Instead all nodes are considered peers • May each act as client, server or both • Node must join P2P network
Web-Based computing • Web has become ubiquitous • More devices becoming networked to allow web access, such as work stations, PDA, even cell phone
Operating System Services • User interface • Program execution • File-system manipulation • Communication • Error detection • Resource allocation • Accounting • Protection and security