Lecture 2 Page 1 CS 111 Online System Services for OSes One major role of an operating system is providing services – To human users – To applications.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
Introduction CSCI 444/544 Operating Systems Fall 2008.
Lecture 12 Page 1 CS 111 Online Devices and Device Drivers CS 111 On-Line MS Program Operating Systems Peter Reiher.
Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
1: Operating Systems Overview
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Operating Systems CS208. What is Operating System? It is a program. It is the first piece of software to run after the system boots. It coordinates the.
Threads CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Computer Organization
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Lecture 1 Page 1 CS 111 Online Introduction to the Course Purpose of course and relationships to other courses Why study operating systems? Major themes.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
Protection and the Kernel: Mode, Space, and Context.
Systems Security & Audit Operating Systems security.
LOGO OPERATING SYSTEM Dalia AL-Dabbagh
Operating System Review September 10, 2012Introduction to Computer Security ©2004 Matt Bishop Slide #1-1.
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
Threads, Thread management & Resource Management.
Operating Systems Lecture 2 Processes and Threads Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Processes and OS basics. RHS – SOC 2 OS Basics An Operating System (OS) is essentially an abstraction of a computer As a user or programmer, I do not.
OPERATING SYSTEMS Goals of the course Definitions of operating systems Operating system goals What is not an operating system Computer architecture O/S.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Computers Operating System Essentials. Operating Systems PROGRAM HARDWARE OPERATING SYSTEM.
Chapter 1: Introduction and History  Where does the operating system fit in a computing system?  What does the operating system achieve?  What are the.
1: Operating Systems Overview 1 Jerry Breecher Fall, 2004 CLARK UNIVERSITY CS215 OPERATING SYSTEMS OVERVIEW.
Lecture 5 Page 1 CS 111 Online Processes CS 111 On-Line MS Program Operating Systems Peter Reiher.
Lecture 5: Threads process as a unit of scheduling and a unit of resource allocation processes vs. threads what to program with threads why use threads.
Introduction to Operating Systems and Concurrency.
Lecture 2 Page 1 CS 111 Fall 2015 Operating System Basics CS 111 Operating Systems Peter Reiher.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Concurrency, Processes, and System calls Benefits and issues of concurrency The basic concept of process System calls.
Department of Computer Science and Software Engineering
Lecture 4 Page 1 CS 111 Online Modularity and Virtualization CS 111 On-Line MS Program Operating Systems Peter Reiher.
Lecture 2 Page 1 CS 111 Spring 2015 Operating System Basics CS 111 Operating Systems Peter Reiher.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Lecture 2 Page 1 CS 111 Winter 2014 Operating System Basics CS 111 Operating Systems Principles Peter Reiher.
Concepts and Structures. Main difficulties with OS design synchronization ensure a program waiting for an I/O device receives the signal mutual exclusion.
Major OS Components CS 416: Operating Systems Design, Spring 2001 Department of Computer Science Rutgers University
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Lecture 5 Page 1 CS 111 Online Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Modularity Most useful abstractions an OS wants to offer can’t be directly realized by hardware Modularity is one technique the OS uses to provide better.
Introduction to Operating Systems
CE 454 Computer Architecture
Memory Protection: Kernel and User Address Spaces
CS 6560: Operating Systems Design
Lecture 1 Runtime environments.
Modularity and Memory Clearly, programs must have access to memory
Memory Protection: Kernel and User Address Spaces
Introduction to Operating Systems
Memory Protection: Kernel and User Address Spaces
Memory Protection: Kernel and User Address Spaces
Lecture Topics: 11/1 General Operating System Concepts Processes
CS510 Operating System Foundations
CSE 153 Design of Operating Systems Winter 2019
CS703 – Advanced Operating Systems
Memory Protection: Kernel and User Address Spaces
Presentation transcript:

Lecture 2 Page 1 CS 111 Online System Services for OSes One major role of an operating system is providing services – To human users – To applications What services should an OS provide?

Lecture 2 Page 2 CS 111 Online An Object Oriented View of OS System Services Services are delivered through objects – Can be instantiated, named, and destroyed – They have specified properties – They support specified methods To understand a service, study its objects – How they are instantiated and managed – How client refers to them (names/handles) – What a client can do with them (methods) – How objects behave (interface specifications)

Lecture 2 Page 3 CS 111 Online Typical OS System Service Types Execution objects – Processes, threads, timers, signals Data objects – Files, devices, segments, file systems Communications objects – Sockets, messages, remote procedure calls Protection objects – Users, user groups, process groups Naming objects – Directories, DNS domains, registries

Lecture 2 Page 4 CS 111 Online System Services and Abstractions Services are commonly implemented by providing appropriate abstractions For example, – The service of allowing user code to run in a computing environment – Requires a couple of abstractions, at least: The virtual environment abstraction The process abstraction

Lecture 2 Page 5 CS 111 Online The Virtual Environment Abstraction A CPU executes one program at a time – It is a serially reusable resource But we want to run multiple programs “simultaneously” – Without them treading on each other’s toes A good way to do that is to build a virtual execution environment abstraction – Make it look like each program has its own computer

Lecture 2 Page 6 CS 111 Online What Should This Abstraction Provide? Each program should see its own resource set – A complete virtual computer with all elements CPU Memory Persistent storage Peripherals Isolation from other activities – Including non-related OS activities Each program should think it has the real machine to itself

Lecture 2 Page 7 CS 111 Online How To Do That? We won’t go into detail now – But will later In essence, the OS must multiplex its real resources – Among the various process’ virtual computers Requiring care in saving and restoring state And attention to fair use and processes’ various performance requirements

Lecture 2 Page 8 CS 111 Online The Process Service Given we want per program virtual environments, We need an abstraction that provides the ability to run user code – The process With some very useful properties: – Isolation from other code – Isolation from many system failures – Guarantees of access to certain resources Processes can communicate and coordinate – But do so through the OS – Which provides isolation and synchronization

Lecture 2 Page 9 CS 111 Online What Is a Process? A virtual computer that executes a single program – It provides illusion of continuous execution – Despite fact that CPU is being time-shared Runs process A, then process B, then process A What virtual environment does a program see? – Programs don't run on a real bare computer – They run inside of a process – Process state is saved when it is not running – Process state is restored when it runs again

Lecture 2 Page 10 CS 111 Online Processes and Programs Program = set of executable instructions – Many processes can run the same program Process = executing instance of program – It has saved state Memory, contents, program counter, registers,... – It has resources and privileges Open files, user-ID, capabilities,... – It may be the unit of CPU sharing CPU runs one process, then another

Lecture 2 Page 11 CS 111 Online Problems With the Process Abstraction Processes are very expensive – To create: they own resources – To dispatch: they have address spaces Different processes are very distinct – They cannot share the same address space – They cannot (usually) share resources Not all programs want strong separation – Cooperating parallel threads of execution – All are trusted because they run same code

Lecture 2 Page 12 CS 111 Online So the Process Abstraction Isn’t Sufficient To meet common user needs What if I have a program that can do multiple things simultaneously? And requires regular, cheap communications between those different things? Processes are too expensive And make regular communications costly So I need another abstraction

Lecture 2 Page 13 CS 111 Online Threads An abstraction built on top of the process abstraction Each process contains one or more threads Each thread has some separate context of its own – Like a program counter and scheduling info But otherwise shares the resources of its process Threads within a process can thus communicate easily and cheaply

Lecture 2 Page 14 CS 111 Online Characteristics of Threads Strictly a unit of execution/scheduling – Each thread has its own stack, PC, registers Multiple threads can run in a process – They all share the same code and data space – They all have access to the same resources – This makes the cheaper to create and run Sharing the CPU between multiple threads – User level threads (with voluntary yielding) – Kernel threads (with preemption)

Lecture 2 Page 15 CS 111 Online Using the Abstractions When a programmer wants to run code, then, he can choose between abstractions Does he want just a process? Or does he want a process containing multiple threads? Or perhaps multiple processes? – With one thread each? – With multiple threads?

Lecture 2 Page 16 CS 111 Online When To Use Processes When running multiple distinct programs When creation/destruction are rare events When running agents with distinct privileges When there are limited interactions and few shared resources When you need to prevent interference between processes – Or need to protect one from failures of the other

Lecture 2 Page 17 CS 111 Online An Example of Choosing Processes When implementing compilation in a shell script cpp $1.c | cc1 | ccopt > $1.s as $1.s ld /lib/crt0.o $1.o /lib/libc.so mv a.out $1 rm $1.s $1.o Each of these programs gets a separate process

Lecture 2 Page 18 CS 111 Online Why? The activities are serial The only resources to be shared are through the file system Failure of one program could damage the others if too much is shared – Who knows what rm might get rid of, for example?

Lecture 2 Page 19 CS 111 Online When To Use Threads When there are parallel activities in a single program When there will be frequent creation and destruction When all activities can run with same privileges When they need to share resources When they exchange many messages/signals When there’s no need to protect them from each other

Lecture 2 Page 20 CS 111 Online An Example for Choosing Threads A telnet implementation For a given session, the user will both read and write data The reading and writing activities share some important state – Like who they’re connected to But can be performed in parallel

Lecture 2 Page 21 CS 111 Online Which Abstraction Should You Choose? If you use multiple processes – Your application may run much more slowly – It may be difficult to share some resources If you use multiple threads – You will have to create and manage them – You will have serialize resource use – Your program will be more complex to write TANSTAAFL – There Ain't No Such Thing As A Free Lunch

Lecture 2 Page 22 CS 111 Online Generalizing the Concepts There are many other abstractions offered by the OS Often they provide different ways of achieving similar goals – Some higher level, some lower level The OS must do work to provide each abstraction – The higher level, the more work Programmers and users have to choose the right abstractions to work with

Lecture 2 Page 23 CS 111 Online Abstractions and Layering It’s common to create increasingly complex services by layering abstractions – E.g., a file system layers on top of an abstract disk, which layers on top of a real disk Layering allows good modularity – Easy to build multiple services on a lower layer E.g., multiple file systems on one disk – Easy to use multiple underlying services to support a higher layer – E.g., file system can have either a single disk or a RAID below it

Lecture 2 Page 24 CS 111 Online A Downside of Layering Layers typically add performance penalties Often expensive to go from one layer to the next – Since it frequently requires changing data structures or representations – At least involves extra instructions Another downside is that lower layer may limit what the upper layer can do – E.g., an abstract disk prevents disk operation reorderings to maximize performance

Lecture 2 Page 25 CS 111 Online Layer Bypassing Often necessary to allow a high layer to access much lower layers – Not going through one or more intermediaries Most commonly for performance reasons If the higher layer plans to use the very low level layer’s services, – Why pay the cost of the intermediate layer? Has its downsides, too – Intermediate layer can’t help or understand

Lecture 2 Page 26 CS 111 Online Hardware/Software Layering Operating System System Call Interface Hardware Standard instruction set Privileged instruction set (arithmetic, logical, copy, test, flow-control operations,... ) System Services/Libraries Application Binary Interface (e.g. string, random #s, encryption,graphics...) Applications Software (e.g. word processor, compiler, VoIP client,...)