430 likes | 441 Views
This lecture provides an introduction to operating systems, discussing their design, purpose, and significance. It covers topics such as system architecture, concurrent programming, and the role of operating systems in facilitating and optimizing computer systems.
E N D
Operating Systems Lecture 1: IntroductionReview of System Architecture and Concurrent Programming Maxim Shevertalov Jay KothariWilliam M. Mongan Operating Systems
Introduction • What is an Operating System? • How are they designed? • Why study them? Operating Systems
What is an Operating System? • Facilitation + Performance • Think of Air Traffic Control: they are in charge of lots of airplanes, and sometimes they tell airplanes to wait their turn. • Despite what we may sometimes think, their intent is not to prevent us from doing what we want by imposing complicated rules. • Rather, they are there to facilitate aircraft in flight. • On its own, the air traffic controller does not accomplish much; but, together with the aircraft he supports, he aims to maximize performance for all the participating airplanes (not any one!), while protecting them from one another. • It’s all about coordination. Operating Systems
What is an Operating System? • Can we use a computer system without an operating system? Operating Systems
What is an Operating System? • Can we use a computer system without an operating system? • We would have to directly interface with the computer hardware. • Pros: speed?, control? • Cons: What if we need to run on a different machine?Or change the network card? Install a new OS? What if new features like multiprocessors or a cluster is introduced to the program? • The operating system mediates between application (the airplanes) and the shared resources (the runways and airspace) in a way that provides abstraction and generality for the applications. Operating Systems
What is an Operating System? • Trusted software interposed between the hardware and application/utilities to improve efficiency and usability • Most computing systems have some form of operating systems • Hard to use computer systems without OS Applications and Utilities Operating System Computer Hardware Operating Systems
Why Study Them? • Take a deeper at system architecture • Modular, layered software design • All of our software runs on top of it! It is the common denominator of everything we write. • How often do you make a syscall? Or invoke some system library? • Learn to build complex systems • Engineering Issues • Business Issues (OS as a government) • Security (viruses, worms, etc.) Operating Systems
CPU CPU Disk Controller USB Controller GPU CPU Memory Computer System Organization • Computer-system operation • One or more CPUs, device controllers connect through common bus providing access to shared memory • Concurrent execution of CPUs and devices competing for memory cycles Operating Systems
Operating System Design: Modularity • Process Control: Threads • Synchronization and Scheduling • Protection, Memory Management, Caching • Demand Paging • File Systems • Networking and Distributed Systems • Protection and Security Operating Systems
One Size Fits All? Requirements Dictate Design Operating Systems
Evolution of the OS • In the beginning... Computers • Cost millions of $$$ • Were hard to operate (performed using console switches) • Were hard to program (in particular I/O devices) Operating Systems
Utilizing Expensive Hardware • Expensive computers could not idle; utilization should be very high • Batch processing was devised • Programming done offline and subroutine were created for common tasks • I/O and processing overlap obtained via buffering and interrupts Operating Systems
Factors in OS Evolution • Cost of computers (i.e., computer time) • Cost of people (i.e., user time) early batch systems time sharing systems computer utilization personal systems user wait time Operating Systems
Major OS Functions Operating Systems
Major OS Functions • Control access and provide interfaces • To the OS and devices attached to the system • Provide interfaces for human-machine and machine-machine transactions • Manage resources • Mediate resource usage among different tasks • Implement policies Operating Systems
Major OS Functions • Control access and provide interfaces • To the OS and devices attached to the system • Provide interfaces for human-machine and machine-machine transactions • Manage resources • Mediate resource usage among different tasks • Implement policies • Provide abstractions • Hide the peculiarities of the hardware. • Example: device independent I/O • Consume resources • OS runs on the system that is being managed… so it is going to consume resources! Operating Systems
What is the Access Problem? • User wants to access OS, why? • User wants to access devices connected to the system • It all starts with recognizing the user’s intent to access! Operating Systems
Access Problem: Handling I/O • Programmed I/O • The CPU transfers the data from (or to) the device buffers. • After issuing an I/O operation the CPU continuously checks (polls) for its completion Operating Systems
Access Problem: Handling I/O • Interrupt-driven I/O (slow speed, character device) • The CPU issues an I/O operation and goes on; Device notifies (interrupts) the CPU as data arrives; CPU processes the data Operating Systems
How Does the OS Service Interrupts? Operating Systems
Access Problem: Data Processing • Once data is captured from device (e.g., keyboard) what is next? • Imagine you want to write a word processor • Capture some keystrokes – for arrow and other control keys • Capture words (cooked or raw form?) Operating Systems
Accessing Devices vs. OS Services • OS interposes itself between the hardware and applications/utilities/users • Controlling access to OS ---> Controls device access User OS Device Operating Systems
How Do You Control Access to the OS? • Provides a two level architecture: • Trusted mode • Untrusted mode • The OS (at least the core part – called Kernel) runs in the trusted mode • User applications/utilities run in the untrusted mode Operating Systems
System Call via Trap • OS provides system calls for accessing OS services from applications • System calls are special procedure calls • Control transfer • Switch protection domain • System calls also: • Validate the call • Allow authorized actions to take place Operating Systems
How are Syscalls Processed? Operating Systems
UNIX Syscall Examples • Process control • fork(), exec(), wait(), abort() • File manipulation • chmod(), link(), stat(), creat() • Device manipulation • open(), close(), ioctl(), select() • Information maintenance • time(), acct(), gettimeofday() • Communications • socket(), accept(), send(), recv() Operating Systems
How Does an OS Manage Resources? Operating Systems
Process: Avatar of the Application • A process represented process table entry Operating Systems
Simple Process Model • Below is a two-state process model • Running (on the CPU) • Not running (waiting to get the CPU or at I/O) Operating Systems
Resource Management: Processor Time • Processor time is the primary resource managed by the OS • How it is managed depends on the type of OS: • Batch vs Time-sharing • Uniprogramming vs Multiprogramming Operating Systems
Example: Uniprogramming (only one program running on the system) What is the CPU Utilization? Operating Systems
Example: Multiprogramming(multiple programs simultaneously running) Operating Systems
Comparing System Utilization Operating Systems
Process Scheduling Operating Systems
Process Scheduling: Concerns Operating Systems
Process Scheduling Concerns • Fairness • Give equal and fair access to resources • Differential responsiveness • Discriminate among different classes of jobs • Efficiency • Maximize throughput, minimize response time, and accommodate as many users as possible Operating Systems
Memory Management • Memory management is key to multiprogramming • Memory is a space sharing resource • Memory management is necessary to protect co-residing programs from each other • Depending on the occupancy pattern, a program would not know the location until load time • Memory management should provide: • Protection • Relocation Operating Systems
How Does an OS Manage Memory? • Idea: • Divide the memory into partitions and allocate them to different processes • Partitions can be fixed size or variable size • A process • Cannot access memory not allocated to it • Can request more memory from OS • Can release already held memory to OS • May only use a small portion of the allocated memory Operating Systems
How Does an OS Manage Memory? • We can load more processes than that fitting the memory • Where do the rest go? Answer: Virtual Memory Operating Systems
Virtual Memory in Action • Some memory chunks (pages) are in memory • Rest in disk • OS is responsible for retrieving the pages from and flushing the pages to disk Operating Systems
To Use Storage, We Need a Filesystem Operating Systems
Storage Management: Component View Operating Systems
Topics Covered • Fundamentals (Operating Systems Structures) • Process Control and Threads • Synchronization and scheduling • Protection, Address translation, Caching • Demand Paging • File Systems • Networking and Distributed Systems • Protection and Security Operating Systems