CPS221 Lecture: Operating System Functions

Similar documents
CPS221 Lecture: Operating System Functions

What is UNIX? A Little Bit about UNIX and User Interfaces. Adapted from Practical Unix and Programming Hunter College

CS420: Operating Systems. OS Services & System Calls

TDDI04, K. Arvidsson, IDA, Linköpings universitet Operating System Structures. Operating System Structures Overview. Operating System Services

Operating System Services

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Chap2: Operating-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edit9on

Chapter 2: Operating-System Structures

The Slide does not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams.

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Chapter 2: Operating-System Structures

Chapter 2: Operating-System Structures. Operating System Concepts Essentials 8 th Edition

Chapter 2: Operating-System

ELEC 377 Operating Systems. Week 1 Class 2

Chapter 2: Operating-System Structures

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Operating Systems. Copyleft 2005, Binnur Kurt

CS370 Operating Systems

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Chapter 2: Operating-System Structures. Chapter 2: Operating-System Structures. Objectives. Operating System Services

Chapter 2: Operating-System Structures

Lecture 2 Operating System Structures (chapter 2)

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

CPS221 Lecture: Operating System Protection

Chapter 2: System Structures

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

CS 390 Chapter 2 Homework Solutions

Objectives. Chapter 2: Operating-System Structures. 2.1 Operating System Services

CS307: Operating Systems

Operating System Structure

What are some common categories of system calls? What are common ways of structuring an OS? What are the principles behind OS design and

Unix/Linux: History and Philosophy

CPS221 Lecture: Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 2. Operating-System Structures

Lecture 2 - Fundamental Concepts

Operating System Structure

Operating-System Structures

Operating Systems CS3502 Spring 2018

Chapter 2 Operating-System Structures

Chapter 2: Operating-System Structures

Lecture 2: September 9

Chapter 2: Operating-System Structures. Operating System Concepts 9 th Edition

Problem Set: Processes

Chapter 2: Operating-System Structures. Operating System Concepts 8 th Edition

Chapter 2: System Structures

Operating Systems Overview. Chapter 2

EECS 3221 Operating System Fundamentals

EECS 3221 Operating System Fundamentals

What we saw. Desarrollo de Aplicaciones en Red. 1. OS Design. 2. Service description. 1.1 Operating System Service (1)

Distributed Systems Operation System Support

OS structure. Process management. Major OS components. CSE 451: Operating Systems Spring Module 3 Operating System Components and Structure

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Unit 2 : Computer and Operating System Structure

5/8/2012. Specifying Instructions to the Shell Chapter 8

CHAPTER 2: SYSTEM STRUCTURES. By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Chapter 2: System Structures. Operating System Concepts 9 th Edition

Overview of Unix / Linux operating systems

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

Linux Operating System

Operating System Architecture. CS3026 Operating Systems Lecture 03

The modularity requirement

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Introduction to PC Operating Systems

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Introduction to Linux

EECS2301. Lab 1 Winter 2016

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Introduction to Linux

Unix Shells and Other Basic Concepts

Chapter 4: Multithreaded Programming. Operating System Concepts 8 th Edition,

Overview of Operating Systems

Problem Set: Processes

The UNIX Operating System. HORT Lecture 2 Instructor: Kranthi Varala

Introduction to Cygwin Operating Environment

Linux & Shell Programming 2014

Introduction to Linux

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Chapter 2 Software Components

Definition: An operating system is the software that manages resources

Process Description and Control

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

The Online Unix Manual

Introduction to Linux. Fundamentals of Computer Science

Overview of Operating Systems

CISC 220 fall 2011, set 1: Linux basics

Module 1 Introduction/OS Overview

Introduction. Let s start with the first set of slides

OS concepts and structure. q OS components & interconnects q Structuring OSs q Next time: Processes

13-2 EE 4770 Lecture Transparency. Formatted 8:18, 13 March 1998 from lsli

OS - Introduction Ezio Bartocci Institute for Computer Engineering

An Overview of the BLITZ System

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

CPSC 341 OS & Networks. Introduction. Dr. Yingwu Zhu

Transcription:

CPS221 Lecture: Operating System Functions Objectives 1. To overview key hardware concepts 2. To introduce the process concept 3. To discuss the various kinds of functionality of the OS last revised 8/25/11 Materials 1. Projectable of structure with middleware 2. Ability to show Mac Utillities, System Preferences I. Introduction A. Operating systems play a central role in the operation of most computer systems. In fact, when one speaks of a computer system, one often refers to the operating system - e.g. a Windows machine or a Linux machine or a Macintosh (Only in the latter case does the name say anything about the hardware, and only because MacOS only runs on machines made by Apple). B. In essence, what the operating system does is to create a layer of abstraction around the basic hardware, such that the user does not see the actual underlying machine, but rather a virtual machine that the operating system provides: User Application Programs Operating System Hardware 1. The user and the application programs do not see the hardware directly, but only through the operating system. 2. One benefit of this abstraction is that it hides differences in machines from the user, so that the user can focus on the general solution to his problem, rather than the intricacies of a particular machine it runs on. This facilitates portability of programs. 3. The UNIX operating system has carried this even further. 1

a) Most operating systems are specific to a particular type of CPU and even manufacturer. (e.g. the 80x86 family for Windows; 80x86 made by Apple for MacOS), b) UNIX and Unix-like systems (including Linux) have been implemented on many different CPU's. Application programs may, of course, need to be recompiled for a particular hardware architecture, since the machine language is different; but the basic UNIX file system and system services is the same in all cases, so that Unix-like programs are highly portable from machine to machine. C. One way to view an operating system is in terms of four basic interfaces: 1. The interface to the underlying hardware (specific to a particular machine). A modern operating system is responsible for managing five general categories of hardware resources: a) The CPU itself b) Primary memory c) Various sorts of IO devices (1) One user at a time devices like a printer, keyboard, or monitor (2) The file system (3) Networking capabilities 2. The interface to application programs (should look the same whereever a given operating system is implemented) 3. The interface to the user (command language, utilities) 4. The interface to system management capabilities. D. Each of these interfaces provides a "view" of the operating system that is important to certain kinds of people. 1. People who build interfaces for new kinds of hardware devices are, of course, most interested in the operating system's hardware interface. 2. Application programmers are primarily interested in the operating system's program interface - though they also use the user interface in their work. 2

3. Many users are only interested in the user interface. Indeed, many popular books about particular operating systems deal primarily with this aspect. 4. More sophisticated users and system managers are also concerned with the administrative interfaces. E. Many operating systems are delivered as three major components: a kernel plus a collection of libraries plus a collection of system programs. 1. The core of the operating system (the operating system proper) provides the first interface, plus some additional functionality we will discuss. 2. The libraries provide the second interface, relying on mechanisms provided by the operating system proper. 3. The system programs provide the latter two, relying on mechanisms provided by the operating system proper and the libraries. 4. Our principal focus in the course will be on the hardware and the application program interface, though we will say a bit about the user and management interfaces. II. The Operating System Proper A. As we just said, the operating system interacts directly with underlying hardware. To support protection on a multiuser system, certain hardware operations are restricted to only be performed by the operating system. (We call these kernel operations, and we will talk later about how this restriction is achieved.) 1. All input-output operations - so that the OS can ensure that a given user only performs permissible file accesses and other operations. 2. Operations that control access to various regions of memory - so that the OS can ensure that users do not interfere with one another or with the functioning of the OS itself. 3. Certain other privileged operations, such as halting the CPU. B. One of the key responsibilities of the operating system is to manage a collection of processes. 3

1. A process is a program in execution. At any given time, the status of a process includes: a) A region of memory that contains the code that it is executing. plus the values of its variables. b) One or more threads of execution (1) Historically, processes have typically had a single thread of execution. But as we shall see soon, for various reasons it is often desirable to have multiple threads of execution within a single process. (2) Each thread of execution has: (a) A state. At any given time, a thread of execution may either by ready to use the CPU, or waiting for some event to occur before it can proceed further (b) A set of contents of the various CPU registers - particularly the program counter, which indicates the location in memory of the instruction the process is about to execute next. c) Note the difference between a program and a process - a process is a program in execution. (1) When a program is running, there is generally a one-to-one correspondence between the program and the process running it. (2) However, it is possible that some programs, when run, may give rise to multiple processes. (3) Conversely, a single process may run different programs over the course of its life. 2. At any given time, a system may running several types of processes. a) Some processes are providing service directly to users - e.g command interpreters, application programs, utilities. Example: as I am writing this, at least three processes I am aware of are currently running on my computer - one running my word processor, my email program, and a web browser. 4

b) Some processes may be server processes providing services to other computers on the network - perhaps with multiple threads of execution if servicing multiple users. c) Others processes are providing operating system functions that the user may not be consciously aware of. 3. The kernel provides a number of services concerned with the management of processes - e.g. services that create processes, allow processes to terminate (either normally or in error) and (sometimes) that allow processes to communicate with or control other processes. C. Another major task of the operating system is resource allocation. There is a sense in which the various processes on the system are in competition for various system resources, and it is the kernel's task to apportion them appropriately. 1. This issue arises on a system that supports multiple users, or on a system that multitasks for a single user. 2. One such resource is the CPU. a) On a one-cpu system, only one process can actually be executing on the CPU at a time. (If the system has multiple CPU s or is multicore, the number may be greater than one but still typically much less than the number of processes in existence). b) If there are multiple processes that could use the CPU, the operating system must determine which process gets it, and for how long. 3. Memory is another resource to be allocated. Each process needs one or more regions of memory to hold its code and data. 4. Another resource to be managed is the various IO devices. a) One user at a time devices b) The file system c) Network connections. D. Another task is providing support services needed by processes. These include: 5

1. Support for IO operations, so that application programs can be shielded from hardware-specific details. This can be very sophisticated on windowing systems, where a single physical display is shared by multiple processes through individual windows that can overlap one in various ways. 2. File system management (directory structures, etc.) 3. Networking to other systems. 4. Of course, the operating system should also guarantee processes protection from interference by other processes. E. The heart of the operating system is a collection of routines that are normally entered as a result of hardware interrupts or traps. 1. Most of the time the CPU is executing code on behalf of a user process. 2. The operating system contains a collection of handlers. The execution of one of these is triggered by events like: a) Completion of an IO operation that has been requested b) A request for a service provided by the OS kernel, such as IO c) An invalid operation, such as the dreaded NullPointer exception 3. In any case, after servicing the event, the OS handler code resumes the running of some user process - either the one that was running before, or some other process. III. Libraries - the API A. All operating systems provide a collection of routines that can be used by application programs - commonly called the API. B. An operating system API includes routines that correspond directly to the various system services, but provide a more straightforward interface. Example: On Unix systems, each of the system service calls is given a number, which is specified (together with other parameters) when the system service is invoked. For each system service, the API also defines a routine that takes the correct number of arguments and supplies the service number. 6

For example, the function read() with three arguments executes a trap with code 3 - which corresponds to the read system service. C. Typically, an API also provides a large number of routines that provide more general support application programs (including things like mathematical functions as well system type operations.) 1. For example, there is a family of IEEE standards for Unix and Unixlike API s known as POSIX (Portable Operating System Interface [for Unix] a) Most versions of Unix (including MacOSX) fully support POSIX. b) Linux mostly supports POSIX c) Microsoft provides an add-on for some versions of Windows that provides full support for the POSIX API. 2. Both Windows and MacOS include extensive libraries as part of the OS distribution D. There is a somewhat blurry line between API libraries and middleware. The term middleware refers to an add-on API that facilitates cooperation between processes, possibly running on multiple machines. 1. Examples: Microsoft.NET, web servers, Object-request brokers, remote procedure call facilities, etc. 2. In practice, the line is often drawn between the API furnished by the operating system, per-se, and that furnished by add-on software - so we get a situation that looks like this: PROJECT APPLICATIONS MIDDLEWARE OPERATING SYSTEM 7

IV. System Programs A. Operating Systems also include a collection of system programs thar can be run when needed. (When such a program is running it gives rise to a process that the kernel manages like other processes.) B. One important kind of system program is the program that provides the user interface to the rest of the system. 1. This can take on of two forms a) A command interpreter that reads textual commands and performs them. DEMO: Shell b) A graphical user interface 2. Systems often provide several interfaces like this that the user can choose from. a) On both the Macintosh and Windows, the normal user interface is via a GUI. b) But on both systems, it is possible to access a command-line interface (as was just demonstrated on a Macintosh). c) On Unix/Unix-like systems, the system can be configured to start up with either a command-line or a GUI interface, but it is always possible to access a command-line when running a GUI interface. d) In the Unix world, the command line is known as the shell, and Unix or Unix-like systems often include a number of different shells that the user can choose from. (1) Both our Linux machines and Mac OSX have the following shells (a) The Bourne shell (named after its developer Steven Bourne) - (known by the name sh) (b) A GNU-variant known as the Bourne again shell (bash) (c) The Korn shell (ksh) 8

(d) The C-Shell - a shell with syntax that resembles the C programming language (csh) (e) A variant of the C Shell (tcsh) (f) The Z shell (zsh) (2) Unix shells have many of the features of a programming language, making it possible to create shell scripts in which the primitive operations are actually the execution of various programs 3. The user interface (whether a GUI or a command line) allows the user to perform various file system operations (e.g examining directories, moving, renaming, or deleting files) as well as to run programs. a) In a GUI, these capabilities are typically part of the GUI. b) With a shell, they may be built into the shell, or provided by system programs that the shell runs. Example: to delete a file on a Unix-like system, one uses the shell command rm, which runs a program known as rm. C. Other system programs support the user interface or provide other utility or administrative services. Example: Show /Applications/Utilities on a Macintosh - describe/demo a few programs Example: Show System Preferences on the Macintosh - describe/demo a few panes 9