CS552 Overview © 2009, D. J. Foreman1. Generalized O/S structure Basic interrupt handler – Determines cause – Uses branch table to specific handler I/O.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
CS4315A. Berrached:CMS:UHD1 Operating Systems and Computer Organization Chapter 4.
Computer System Overview
Chapter 6 Limited Direct Execution
Features of Intel Processor Architectures that Lend to Operating System Design Jim Snyder.
1 Operating Systems and Protection CS Goals of Today’s Lecture How multiple programs can run at once  Processes  Context switching  Process.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
© 2009, D. J. Foreman 1 Computer Organization. © 2009, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
OS Spring’03 Introduction Operating Systems Spring 2003.
Introduction to Interrupts
OS Spring’04 Introduction Operating Systems Spring 2004.
Chapter 2 The OS, the Computer, and User Programs Copyright © 2008.
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
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.
Three fundamental concepts in computer security: Reference Monitors: An access control concept that refers to an abstract machine that mediates all accesses.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
2: Computer-System Structures
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 ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
© 2004, D. J. Foreman 1 Implementing Processes and Threads.
© 2004, D. J. Foreman 1 Computer Organization. © 2004, D. J. Foreman 2 Basic Architecture Review  Von Neumann ■ Distinct single-ALU & single-Control.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
© 2004, D. J. Foreman 1 Device Mgmt. © 2004, D. J. Foreman 2 Device Management Organization  Multiple layers ■ Application ■ Operating System ■ Driver.
Bootable Programs Building an O/S. Basic Requirements of any O/S Respond to interrupts (all kinds) Preserve user environment Protect users and self from.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
© D. J. Foreman, Structure of an O/S. © D. J. Foreman, Overview  Required functionality –Handle interrupts –Manage resources Processes.
Introduction to Operating Systems Concepts
Interrupts and signals
Microprocessor and Assembly Language
Exceptional Control Flow
Exceptional Control Flow
Anton Burtsev February, 2017
Protection of System Resources
Overview of today’s lecture
Exceptional Control Flow
Computer System Overview
Computer-System Architecture
Module 2: Computer-System Structures
Lecture Topics: 11/1 General Operating System Concepts Processes
Architectural Support for OS
Computer Organization
Module 2: Computer-System Structures
Architectural Support for OS
O/S Organization © 2004, D. J. Foreman.
Module 2: Computer-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Module 2: Computer-System Structures
O/S Organization © 2004, D. J. Foreman.
Chapter 1: Introduction CSS503 Systems Programming
Interrupts and System Calls
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

CS552 Overview © 2009, D. J. Foreman1

Generalized O/S structure Basic interrupt handler – Determines cause – Uses branch table to specific handler I/O manager – Performs I/O for the user’s requests Directly Via drivers – Paging – Basic error handling Scheduler Dispatcher © 2009, D. J. Foreman2

Generalized O/S Operation “Booting” & login Load self into RAM Display logon screen Enter h/w wait state - NO CPU cycles occur Display pressed keys on screen Call logon manager – Create a Process Control Block for user – Create an address space for user – Load GUI code into user’s address space – Load “user mode” state with address of GUI © 2009, D. J. Foreman3

Generalized GUI Operation Create windows and buttons Wait for user interaction – User presses keys or uses mouse I/O interrupt occurs (hardware gate flips) O/S – handles interrupt (in kernel mode) posts a flag for GUI to see – Value of key pressed – position of mouse – Returns to GUI in user mode (always) GUI performs required action on the screen © 2009, D. J. Foreman4

Kernel Basics States State vectors Interrupts Contexts Context switching Reserved RAM © 2009, D. J. Foreman5

Remainder of Course Paging Scheduling & Dispatching Virtualization Multi-tasking File & storage systems Deadlock Security & reliability Distributed systems © 2009, D. J. Foreman6

Basic Computer Architecture © 2009, D. J. Foreman7

Components Elementary instructions – Load – Add, subtract, etc – Store – Compare – Branch Data access – Register(like a pointer) – Displacement offset or “distance in bytes, from register contents © 2009, D. J. Foreman8

Instruction types Risc – Operation code and one operand – e.g.Lx loads content of x into an accumulator CISC – Operation code and TWO operands – e.g.Lx,y loads contents of y into register x © 2009, D. J. Foreman9

States Define current machine capabilities – Interrupts allowed or not – Privileged instructions allowed or not (ie; kernel mode vs. user mode) – Memory protection key or state (# and/or on/off) – Next sequential instruction to perform – Addressing mode – User-mode flag (div by 0, etc) © 2009, D. J. Foreman10

Current State Vector Contains the state information – Is NOT a memory location or data structure Changeable by events (interrupts) – I/O completion or external signals – Machine failure, program failure (÷0), service call Changeable by privileged instructions – Vector is loaded from data in RAM Saved to RAM by hardware events © 2009, D. J. Foreman11

Interrupts © 2009, D. J. Foreman12

Interrupts - Generalized Two types – Hardware(MAY be “turned off” by kernel) I/O Clock/interval timer Program exception (e.g.; div by 0) Paging Addressing (32/64 bit) – Software (Service call - ALWAYS allowed) Program requests for kernel service Machine language instruction causes hardware “trap” – Int 0x80PC style (‘n’ is on stack) – SVCnz/390 style © 2009, D. J. Foreman13

© 2009, D. J. Foreman14 Instruction Processing with Interrupts fetchexecute Interrupts allowed? No yes previous inst Interrupt pending? No process interrupt yes

© 2009, D. J. Foreman15 Trap or System Call Instruction Atomic operation – Causes an interrupt (type=service request) – Kernel processes normally Common service request handler – Uses code to select address in trap table – Trap table contains addresses of specific programs for specific request

© 2009, D. J. Foreman16 Traps or Kernel Calls Examples – Cout << x; – Seek (device, position); – X=ftime(); User functions expand into assembly code for a "trap" or "svc" instruction "trap" causes a H/W switch to the kernel Kernel performs op and returns to user

© 2009, D. J. Foreman17 System call example fork (My_fork_loc); {● ● trap (K_FORK, *My_fork_loc); } My_fork_loc:…; *Do_fork Do_fork(loc) { ● ● start_process (loc); mode=0; return; } Trap table *Do_fork User spaceKernel space K_fork is entry # for "FORK" Kernel space

x86 specific Interrupts © 2009, D. J. Foreman18

Allowing x86 interrupts The x86 has an interrupt flag (IF) in the FLAGS register. Only for hardware interrupts. cli sets this flag to 0 - disabled sti sets it to 1- enabled Instructions that load values into the FLAGS register (such as popf and iret) may also modify this flag. © 2009, D. J. Foreman19

X86 specific - 2 intarg int0x04 – Calls interrupt handler #4, IF overflow flag is set int0x80 – Calls the service-call handler © 2009, D. J. Foreman20

Example: the setuid system call Coded as: _syscall1(int,setuid, uid_t, uid); expands to: _setuid: subl $4,%exp pushl%ebx movzwl 12(%esp),%eax movl %eax,4(%esp) movl $23,%eax movl 4(%esp),%ebx int $0x80 --->trap into kernel movl %eax,%edx  --return from kernel testl%edx,%edx jgeL2 negl %edx movl %edx,_errno movl $-1,%eax popl %ebx addl $4,%esp ret L2: movl%edx,%eax popl %ebx addl $4,%esp ret © 2009, D. J. Foreman21

z/390 specific Interrupts © 2009, D. J. Foreman22

Allowing z/390 interrupts Program Status Word controls hardware interrupts – Bits 0-7 – Bits (fixedpoint overflow, decimal overflow, exp underflow, significance) LPSW instruction loads all 64 bits of status SSM instruction sets individual bits 0-7 only See slides on setting Machine State © 2009, D. J. Foreman23

Reserved space in RAM Allows software/hardware interaction Different for every machine architecture Key to understanding of machine control Key to understanding of Operating Systems © 2009, D. J. Foreman24

Contexts © 2009, D. J. Foreman25

User Mode Normal programs: – (payroll, taxes, compilers, etc.) Cannot perform ANY privileged instructions Cannot branch or jump into kernel Kernel does not branch or jump to user code – MUST use a “state switch” instruction Must use “exposed” functions via Service Calls © 2009, D. J. Foreman26

Kernel Mode Can access ANY memory Can use ANY instructions NOT for doing “problem solving” Manages users – Pages – Access to CPU – Access to devices (disk, monitor, etc) © 2009, D. J. Foreman27

Context Switching From Kernel To User Set up values for new state vector Save any kernel registers and stack data Atomic state change – Interrupts on – Privilege off – Memory protect on – Set IC © 2009, D. J. Foreman28

Context Switching From User to Kernel Set up values for service call Issue service call (assembler instruction) Atomic state change occurs – Interrupts off – Privilege on – Memory protect off – Set IC to predefined interrupt handler in kernel Save any user’s registers and stack data © 2009, D. J. Foreman29

Reserved RAM Defined in hardware Used by kernel only Same for ANY O/S on that type of machine: – IBM-compatible PC – z/390 – MAC – powerPC – Sun © 2009, D. J. Foreman30

Hex addressIBM z/390 memory content 0IPL PSW or Restart PSW 8IPL CCW1 or Restart old PSW 10IPL CCW2 18External Old PSW 20Supervisor Call Old PSW 28Program Check Old PSW 30Machine Check Old PSW 38I/O Old PSW 58External New PSW 60Supervisor Call New PSW 68Program Check New PSW 70Machine Check New PSW 78I/O New PSW 80External interrupt data 88 (4 bytes)SVC interruption data: 13-14= ILC, 16-31= interruption code (SVC #) paired © 2009, D. J. Foreman31

© 2009, D. J. Foreman32 PC-bootable disk layout 0x00-0x02 jump inst to 0x1e 0x03-0x0aPC manufacturer name 0x0b-0x0csectors/cluster 0x0d-0x0freserved for boot record 0x10-0x10# of FAT's 0x11-0x12# root directory entries 0x13-0x14# logical sectors 0x15-0x15media descriptor 0x16-0x17sectors/FAT 0x18-0x19sectors/track 0x1a-0x10b # surfaces (heads) 0x1c-0x1d# hidden sectors 0x1e-…boot program

Preparing for Interrupts (PC) BIOS loads the initial address of the IDT table into the idtr register Linux init moves & re-inits the table – setup_idt( ) – an assembly language function – fills all of idt_table with ignore(int) – 2 nd pass – fills in true handlers Enable interrupts © 2009, D. J. Foreman33