Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CS 345 Stalling’s Chapter # Project 1: Computer System Overview"— Presentation transcript:

1 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)

2 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

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

4 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)

5 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)

6 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)

7 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)

8 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)

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

10 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)

11

12 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)

13 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)

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

15 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

16 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

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

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

19 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

20 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

21 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

22 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

23 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)

24 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

25 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

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

27 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

28 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

29 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

30 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

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

32 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

33 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

34 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

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

36 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)

37 Memory Protection OS Job 1 Job 2 Job 4 Job 3 256000 300040 420940
256000 300040 420940 880000 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)

38 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)

39 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)

40 Summary…

41 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)

42 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)

43 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)

44 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)

45 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)

46 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)

47 BYU CS 345 OS Overview (Chapter 1)

48 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)


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

Similar presentations


Ads by Google