CS 345 Stalling’s Chapter # Project 1: Computer System Overview

Slides:



Advertisements
Similar presentations
Computer System Organization Computer-system operation – One or more CPUs, device controllers connect through common bus providing access to shared memory.
Advertisements

Computer System Overview
CSCI 4717/5717 Computer Architecture
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Chapter 1 Computer System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
1 Lecture 2: Review of Computer Organization Operating System Spring 2007.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Computer System Overview
1 Computer System Overview OS-1 Course AA
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.
1 CSIT431 Introduction to Operating Systems Welcome to CSIT431 Introduction to Operating Systems In this course we learn about the design and structure.
OS Spring’03 Introduction Operating Systems Spring 2003.
Computer System Overview
Chapter 7 Interupts DMA Channels Context Switching.
Chapter 1 and 2 Computer System and Operating System Overview
Adapted from slides ©2005 Silberschatz, Galvin, and Gagne and Stallings Lecture 2: Computer Systems Overview.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
Chapter 1 and 2 Computer System and Operating System Overview
Computer System Overview Chapter 1. Basic computer structure CPU Memory memory bus I/O bus diskNet interface.
A. Frank - P. Weisberg Operating Systems Functional View of Operating System.
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
1 CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way.
COSC 4P13 Operating Systems : Design and Implementation.
1 Computer System Overview Let’s figure out what’s inside this thing...
System Calls 1.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Chapter 1 Computer System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Computer Systems Overview. Page 2 W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware resources of one.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Computer System Overview Chapter 1. Operating System Exploits the hardware resources of one or more processors Provides a set of services to system users.
Chapter 1 Computer System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
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.
Operating Systems and Networks AE4B33OSS Introduction.
Ihr Logo Operating Systems Internals & Design Principles Fifth Edition William Stallings Chapter 1 Computer System Overview.
Fall 2000M.B. Ibáñez Lecture 25 I/O Systems. Fall 2000M.B. Ibáñez Categories of I/O Devices Human readable –used to communicate with the user –video display.
Operating System Isfahan University of Technology Note: most of the slides used in this course are derived from those of the textbook (see slide 4)
Operating System 1 COMPUTER SYSTEM OVERVIEW Achmad Arwan, S.Kom.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Lecture 1: Review of Computer Organization
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Chapter 1 – Computer Systems. BYU CS 345OS Overview (Chapter 1)2 CS 345 Stalling’s Chapter#Project 1: Computer System Overview 2: Operating System Overview.
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.
1 Computer Architecture. 2 Basic Elements Processor Main Memory –volatile –referred to as real memory or primary memory I/O modules –secondary memory.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Chapter 1 Computer System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
1 Overview Computer System/Operating System Overview.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Computer Systems Overview. Lecture 1/Page 2AE4B33OSS W. Stallings: Operating Systems: Internals and Design, ©2001 Operating System Exploits the hardware.
1 Computer System Overview Chapter 1. 2 Operating System Exploits the hardware resources of one or more processors Provides a set of services to system.
Introduction to Operating Systems Concepts
Computer System Overview
Chapter 1 Computer System Overview
Computer System Overview
BIC 10503: COMPUTER ARCHITECTURE
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Chapter 1 Computer System Overview
Computer System Overview
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Presentation transcript:

CS 345 Stalling’s Chapter # Project 1: Computer System Overview 2: Operating System Overview 4 P1: Shell 3: Process Description and Control 4: Threads P2: Tasking 5: Concurrency: ME and Synchronization 6: Concurrency: Deadlock and Starvation 6 P3: Jurassic Park 7: Memory Management 8: Virtual memory P4: Virtual Memory 9: Uniprocessor Scheduling 10: Multiprocessor and Real-Time Scheduling P5: Scheduling 11: I/O Management and Disk Scheduling 12: File Management 8 P6: FAT Student Presentations BYU CS 345 OS Overview (Chapter 1)

1. Compile and Validate A task is a unit of execution (also referred to as a process). A shell (Command Language Interpreter) is a task that functions as an interface between the user and an Operating System. A shell interprets textual commands coming either from the user’s keyboard or from a script file and executes the commands either directly or creates a new child process to execute the command. For Project 1: Download all the project files from class website. os345.c, os345interrupts.c, os345signals.c os345tasks.c, os345semaphores.c os345.h, os345config.h, os345signals.h os345p1.c, os345p2.c, os345p3.c, os345p4.c, os345p5.c, os345p6.c os345park.c, os345park.h, os345lc3.c, os345lc3.h, os345mmu.c, os345fat.c, os345fat.h Edit os345config.h (if necessary) to select host OS/IDE/ISA. (Only enable one of the following defines: DOS, GCC, MAC, or NET.) Compile and execute your OS. BYU CS 345 Project 1 - Shell

Why CS 345? BYU CS 345 OS Overview (Chapter 1)

Operating Systems What is an operating system? How about… Hard to define precisely, because operating systems arose historically as people needed to solve problems associated with using computers. How about… “Software that makes computing power available to users by controlling the hardware.” “Software executes when nothing else is happening.” “A collection of software modules including device drivers, libraries, and access routines.” BYU CS 345 OS Overview (Chapter 1)

What Does a Modern OS Do? Provides Abstractions: Hardware has low-level physical resources with complicated, idiosyncratic interfaces. OS provides abstractions that present clean interfaces. Goal: make computer easier to use. Examples: Processes, Unbounded Memory, Files, Synchronization and Communication Mechanisms. Provides Standard Interface: Goal: portability. Unix runs on many very different computer systems. BYU CS 345 OS Overview (Chapter 1)

What Does a Modern OS Do? Mediates Resource Usage: Consumes Resources: Goal: allow multiple users to share resources fairly, efficiently, safely and securely. Examples: Multiple processes share one processor. (preemptable resource) Multiple programs share one physical memory (preemptable resource). Multiple users and files share one disk. (non-preemptable resource) Multiple programs share a given amount of disk and network bandwidth (preemptable resource). Consumes Resources: Solaris takes up about 8 Mbytes physical memory (or about $400). BYU CS 345 OS Overview (Chapter 1)

The Future… In the future, computers will continue to become physically smaller and more portable. Operating systems have to deal with issues like disconnected operation and mobility. Media rich information within the grasp of common people - information with psuedo-real time components like voice and video. Operating systems will have to adjust to deliver acceptable performance for these new forms of data. BYU CS 345 OS Overview (Chapter 1)

Finally Operating systems are so large no one person understands whole system. Outlives any of its original builders. The major problem facing computer science today is how to build large, reliable software systems. Operating systems are one of very few examples of existing large software systems, and by studying operating systems we may learn lessons applicable to the construction of larger systems. BYU CS 345 OS Overview (Chapter 1)

Chapter 1 – Computer Systems Let’s figure out what’s inside this thing... Alex Milenkovich

Learning Objectives Describe the basic elements of a computer system and their interrelationship. Explain the steps taken by a processor to execute an instruction. Understand the concept of interrupts and how and why a processor uses interrupts List and describe the levels of a typical computer memory hierarchy. Explain the basic characteristics of multiprocessor and multicore organization. Discuss the concept of locality and analyze the performance of a multilevel memory hierarchy. Understand the operation of a stack and its use to support procedure call and return. BYU CS 345 OS Overview (Chapter 1)

What is a computer system? Objectives Computer Systems What is a computer system? What are the basic elements of a computer system? Registers Interrupts Caching Input/Output Protection BYU CS 345 OS Overview (Chapter 1)

Registers Computer Systems Interrupts Caching Input/Output Protection Objectives Computer Systems Registers Interrupts Caching Input/Output Protection Summary BYU CS 345 OS Overview (Chapter 1)

Registers CPU BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Processor Registers User-visible registers May be referenced by machine language Available to all programs - application programs and system programs Data Registers – can be changed by user Address Registers – could be separate from data register Stack Registers – user / supervisor stacks Condition Codes – results of operations Control and status registers May or may not be visible Program Counter (PC) – address of next instruction Instruction Register (IR) – most recently fetched instruction MAR/MBR – memory reference registers Program Status Word (PSW) – condition codes, interrupts, mode BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Instruction Execution Registers Instruction Execution Processor executes instructions in a program Instructions are fetched from memory on at a time Fetch Cycle Execute Cycle Fetch Next Instruction Execute Instruction START HALT BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Registers Lots of Registers… BYU CS 345 OS Overview (Chapter 1)

Interrupts Computer Systems Registers Caching Input/Output Protection Summary BYU CS 345 OS Overview (Chapter 1)

Interrupts Interrupts The interrupt was the principle tool available to system programmers in developing multi-tasking systems! Improves processing efficiency by allowing the processor to execute other instructions while an I/O operation is in progress A suspension of a process caused by an event external to that process and performed in such a way that the process can be resumed BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Processing of Interrupts Classes of Interrupts Program arithmetic overflow division by zero execute illegal instruction reference outside user’s memory space Timer I/O Hardware failure An interrupt handler determines nature of the interrupt and performs whatever actions are needed Control is transferred to this program Generally part of the operating system BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Interrupt Cycle Processor checks for interrupts If no interrupts fetch the next instruction for the current program If an interrupt is pending, suspend execution of the current program, and execute the interrupt handler HALT Fetch Next Instruction Execute Check for Interrupt: Process Interrupt Fetch Cycle Execute Cycle Interrupt Cycle Interrupts Disabled Enabled START BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Simple Interrupt Processing Interrupts Simple Interrupt Processing Device controller or other system hardware issues an interrupt Save remainder of process state information Processor finishes execution of current instruction Processor signals acknowledgment of interrupt Process interrupt Processor pushes PSW and PC onto control stack Restore process state information Processor loads new PC value based on interrupt Restore old PSW and PC BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Multiple Interrupts 2 Choices Disable Interrupts Allow Interrupts Disable upon entering an interrupt handler Enable upon exiting Allow Interrupts Allow an interrupt handler to be interrupted Priorities? BYU CS 345 OS Overview (Chapter 1)

Multiple Interrupts - Sequential Order Disable interrupts so processor can complete task Interrupts remain pending until the processor enables interrupts After interrupt handler routine completes, the processor checks for additional interrupts What happens to the interrupts that occur when disabled? BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Multiple Interrupts - Priorities Higher priority interrupts cause lower-priority interrupts to wait Causes a lower-priority interrupt handler to be interrupted Example when input arrives from communication line, it needs to be absorbed quickly to make room for more input How does this change interrupt handlers? BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Caching Computer Systems Registers Interrupts Input/Output Protection Summary BYU CS 345 OS Overview (Chapter 1)

Memory Hierarchy More Expensive Faster & Smaller Bigger Slower Caching Memory Hierarchy More Expensive Faster & Smaller Bigger Slower Registers Cache Main Memory Disk Cache Magnetic Disk Magnetic Tape Optical Disk BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Memory Cache Given: Cache: Processor first checks cache Caching Memory Cache Given: Processor speed is faster than memory speed Execution/data localizes Cache: Contains a portion of main memory Invisible to operating system Used similar to virtual memory Increases the speed of memory Processor first checks cache If not found in cache, the block of memory containing the needed information is moved to the cache BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Cache Design Mapping function Replacement algorithm Write policy Caching Cache Design Cache size small caches have a significant impact on performance Block size the unit of data exchanged between cache and main memory hit means the information was found in the cache larger block size more hits until probability of using newly fetched data becomes less than the probability of reusing data that has been moved out of cache Mapping function Determines which cache location the block will occupy Replacement algorithm Determines which block to replace Least-Recently-Used (LRU) algorithm Write policy write a block of cache back to main memory main memory must be current for direct memory access by I/O modules and multiple processors BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Cache Disk Cache I/O Cache Caching Cache Disk Cache A portion of main memory used as a buffer to temporarily to hold data for the disk Disk writes are clustered Some data written out may be referenced again. The data are retrieved rapidly from the software cache instead of slowly from disk I/O Cache Circular buffers Lists Streams BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Input/Output Computer Systems Registers Interrupts Caching Protection Summary BYU CS 345 OS Overview (Chapter 1)

Programmed I/O I/O module performs the action, not the processor Input / Output Programmed I/O I/O module performs the action, not the processor Sets appropriate bits in the I/O status register No interrupts occur Processor is kept busy checking status BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Input / Output Interrupt-Driven I/O Processor is interrupted when I/O module ready to exchange data Processor is free to do other work No needless waiting Consumes a lot of processor time because every word read or written passes through the processor BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Input / Output Direct Memory Access Transfers a block of data directly to or from memory An interrupt is sent when the task is complete The processor is only involved at the beginning and end of the transfer What does this mean with respect to a paged system? BYU CS 345 OS Overview (Chapter 1) Alex Milenkovich

Protection Computer Systems Registers Interrupts Caching Input/Output Summary BYU CS 345 OS Overview (Chapter 1)

Hardware Protection Why protect hardware? From what? How? Shared hardware resources – memory, disk, … Errant programs How? CPU provides 2 modes of operation User Mode (non-privileged) Supervisor mode (privileged) Privileged instructions can only be executed in monitor mode All I/O instructions are privileged BYU CS 345 OS Overview (Chapter 1)

Memory Protection OS Job 1 Job 2 Job 4 Job 3 256000 300040 420940 256000 300040 420940 880000 1024000 We must not allow a program access to memory outside of its space. How? Add two registers Base Limit Use the registers to check every reference 300040 120900 Base Limit BYU CS 345 OS Overview (Chapter 1)

CPU Protection What is there to protect? Timer Configuration CPU as a resource Timer Task Switching uses the timer When process is loaded timer is set Timer is decremented each cycle When time is zero, an interrupt is generated Process is switched Load-timer is a privileged instruction BYU CS 345 OS Overview (Chapter 1)

Protection Protect at all cost? If all I/O instructions are protected, how do you perform input or output? System calls Often the call is a trap to a ISR Control is passed to the ISR which sets the mode bit to monitor mode ISR verifies that parameters are correct ISR executes request, resets mode Control is returned to user program BYU CS 345 OS Overview (Chapter 1)

Summary…

Summary What is an O.S.? Not always a clear definition as to what constitutes an O.S. and what is an application CD-Rom Driver Scandisk Internet Explorer Intermediary between the hardware and the users Allocate resources (CPU, Memory, disk space, etc.) between programs and users efficiently Allow the user to conveniently access data and programs Protect the system from incorrect or malicious programs and users BYU CS 345 OS Overview (Chapter 1)

Hardware Review Elements of a system: Processor Summary Hardware Review Elements of a system: Processor Registers (address, data, control) Instruction cycle (fetch, decode, execute) Interrupts Usually includes hardware and special instructions to help the O.S. manage memory, devices, etc. Memory Different levels (cache, main memory, disk) Operating system will generally manage memory (both RAM and disk), and move data back and forth as required I/O Usually use Interrupts, DMA Operating system usually controls use of I/O devices BYU CS 345 OS Overview (Chapter 1)

Registers Used for frequently accessed items Summary Registers Used for frequently accessed items User-Visible registers – Available to the programmer and compiler Data Registers Address Registers (Index, Segment, Stack Pointer) Condition code/flags Control and Status registers – Used to control the processor Program Counter/Instruction Pointer Memory address/data Processor Status Word Debugging registers Temp registers Memory Management registers BYU CS 345 OS Overview (Chapter 1)

Interrupts Interrupts I/O techniques Summary Interrupts Interrupts Allow I/O devices to get the CPUs attention at regular intervals (Program, Timer, I/O, Hardware failure) Helps the O.S. by reducing the time spent monitoring I/O devices CPU checks for interrupts after each instruction, starts the handler if needed May allow nested interrupts I/O techniques Programmed I/O Interrupt-Driven I/O Direct Memory Access BYU CS 345 OS Overview (Chapter 1)

Interrupts and I/O Handling and Interrupts: Figure 1.10 (pg 23) Summary Interrupts and I/O Handling and Interrupts: Figure 1.10 (pg 23) Device sends interrupt request to CPU CPU finishes current instruction CPU acknowledges request CPU saves PC and PSW CPU loads PC with the address of the first instruction in the interrupt handler (may get help from interrupt request) Interrupt handler starts, often saves other CPU registers and key values Interrupt handler responds to the device Interrupt handler restores CPU registers and key values CPU restores PC and PSW and resumes previous program BYU CS 345 OS Overview (Chapter 1)

Memory Varying types of memory Summary Memory Varying types of memory Registers, Cache, RAM, Disk, CD Vary in speed, size, cost CPU and O.S. try to keep frequently used data in faster memory Cache – Use a small high-speed memory to improve the apparent speed of a larger low-speed memory Keep track of what is currently being used, load into high-speed memory Replacement Algorithm – What do we get rid of when we run out of memory? Write Policy – How do we respond to modifications? BYU CS 345 OS Overview (Chapter 1)

BYU CS 345 OS Overview (Chapter 1)

Topics to Cover… OS Objectives OS Services Resource Manager Evolution Achievements Processes Memory management Information protection and security Scheduling and resource management System architecture BYU CS 345 OS Overview (Chapter 1)