Csc 2405 computer systems ii
Download
1 / 26

CSC 2405: Computer Systems II - PowerPoint PPT Presentation


  • 89 Views
  • Uploaded on

CSC 2405: Computer Systems II. Spring 2012 Dr. Tom Way. Facilities for Programming. Unix cluster Machines: csgate, tanner, degas, cezanne, picasso,rodin, cassatt, gauguin, matisse List displayed when logging into csgate Linux machines felix, helix Logging in to the machines remotely

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CSC 2405: Computer Systems II' - randy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Csc 2405 computer systems ii

CSC 2405: Computer Systems II

Spring 2012

Dr. Tom Way


Facilities for programming
Facilities for Programming

  • Unix cluster

    • Machines: csgate, tanner, degas, cezanne, picasso,rodin, cassatt, gauguin, matisse

    • List displayed when logging into csgate

  • Linux machines

    • felix, helix

  • Logging in to the machines remotely

    • SSH available for download from the CSC website


Key to success
Key to Success

  • Start early to allow time for debugging.


Policies write your own code
Policies: Write your own code

Programming in an individual creative process much like composition. You must reach your own understanding of the problem and discover a path to its solution. During this time, discussions with friends are encouraged. However, when the time comes to write code that solves the problem, such discussions are no longer appropriate

– The program must be your own work –



Central processing unit cpu

Fetch Cycle

Decode Cycle

Execute Cycle

Decode

Instruction

Fetch Next

Instruction

Execute

Instruction

START

Execute

Execute

HALT

START

Instruction

Instruction

Central Processing Unit (CPU)

  • Runs the loop

    Fetch-Decode-Execute

  • Fetch the next instruction from memory

  • Decode the instruction to figure out what to do

  • Execute the instruction and store the result


Fetch decode execute
Fetch-Decode-Execute

  • Where is the “next instruction” held in the machine?

    • a CPU register called the Program Counter (PC) holds the address of the instruction to be fetched next

  • Fetch cycle

    • Copy instruction from memory into Instruction Register (IR)

  • Decode cycle

    • Decode instruction and fetch operands, if necessary

  • Execute cycle

    • Execute the instruction

    • Increment PC by the instruction length after execution

      (assuming that all instructions are the same length)


Device controller
Device Controller

  • Special-purpose processor

  • In charge of a particular

    device type

  • Has registers

    (data, control, status)

  • Has local buffer storage

  • I/O is from the device to local buffer of controller

  • CPU moves data from/to memory to/from local buffer

  • I/O devices and CPU can execute concurrently


I o operation example
I/O Operation Example

Keyboard

c = getchar();

Keyboard Controller

CPU


Input output i o
Input / Output (I/O)

  • To start an I/O operation, the CPU tells the controller:

    • The chunk size be transferred (eg, one character)

    • Goes off to do something else

  • The device controller:

    • Checks registers to determine what to do (read, write)

    • Transfers data to/from device from/to local buffer

    • Informs the CPU when transfer is complete (HOW?)


Hardware interrupts
Hardware Interrupts

  • Hardware may trigger interrupts at any time by sending a signal to the CPU by way of system bus

  • When the CPU is interrupted

    • Stops what it is doing

    • Transfers control to a fixed memory location (Interrupt Vector)


Interrupt vector
Interrupt Vector

  • A table of pointers (addresses) at a fixed memory location

  • Contains addresses of interrupt service routines

  • Indexed by aunique devicenumber

    • Given with the interrupt request

0

1

Interrupt

vector

2

.

.

.

OS code for disk

interrupt

OS code for divide

by zero trap


Interrupt handling
Interrupt Handling

  • The interrupt architecture

    • Must save the Program Counter (PC) prior to transferring control to the interrupt service routine (interrupt handler)

    • Restore PC upon returning from interrupt

  • Interrupt handler

    • Save registers that are to be modified onto the stack

    • Service request (eg, copy data from local buffer in memory)

    • Mark the process blocked on I/O as ready to run

    • Restore registers from the stack

  • Interrupted computation resumes as the point it left off.


When does the cpu check for interrupts

Fetch Cycle

Decode Cycle

Execute Cycle

Decode

Instruction

Fetch Next

Instruction

Execute

Instruction

START

Execute

Execute

HALT

START

Instruction

Instruction

When does the CPU Check for Interrupts?

???


Cpu cycle with interrupts

Fetch Cycle Decode Cycle

Execute Cycle

Interrupt Check

Interrupts disabled

Fetch

Instruction

Check for

Check for

START

Interrupt:

START

Interrupt:

Process Interrupt

Process Interrupt

Interrupts

Enabled

Decode

HALT

Instruction

START

Execute

Execute

Instruction

CPU Cycle with Interrupts

  • Interrupts must be handled quickly

  • Interrupts are a critical part of a computer system

    • They allow a program to be interrupted, so the computer may deal with an urgent event

  • All modern computer systems are interrupt-driven


Direct memory access i o
Direct Memory Access I/O

  • To start an I/O operation, the CPU tells the DMA controller:

    • The chunk size to be transferred (eg, 4096 bytes of data)

    • The memory address where the chunk ought to be stored

  • The DMA controller

    • Accesses the device via its controller

    • Transfers the chunk from/to device to/from system MEMORY

    • Interrupts CPU when transfer is complete

  • Benefits

    • The CPU is only involved at the start and end of transfer

    • Interrupts are now less frequent

    • Hence, CPU can do a lot of work between interrupts


Dma example
DMA Example

count = read(fd,buffer,nbytes);

Memory

Disk drive

Disk Controller

CPU


Where does the os fit

Operating System

Where Does the OS Fit?

Music

Player

Web

Browser

Users

and

User Programs

System Calls

Interrupts

Device Control


Software interrupts

Users and User Programs

Operating System

Hardware

Software Interrupts

  • Software may trigger interrupts by system calls or illegal operations (such as invalid memory access, divide by zero)

System Calls


System call example 1
System Call Example (1)

  • What happens when a user executes a system call such as read? In Unix, for instance:

    count = read(fd,buffer,nbytes)

    which reads up to nbytes from the file described by fd into buffer. The actual number of bytes read is returned

  • Steps:

    • Push third parameter on to the stack.

    • Push second parameter on to the stack.

    • Push first parameter on to the stack.

    • Call the library routine, which involves pushing the return address on to the stack and jumping to the routine.



System call example 3
System Call Example (3)

  • Machine/OS dependent actions. One is to put the system call number for read in a well defined place, e.g., a specific register. This requires assembly language.

  • Trap to the kernel (assembly language). This enters the operating system properly and shifts the computer to privileged mode.

  • The envelope uses the system call number to access a table of pointers to find the handler for this system call.

  • The read system call handler processes the request (see below).


System call example 4
System Call Example (4)

  • Some magic instruction returns to user mode and jumps to the location right after the trap.

  • The library routine returns (count is also returned).

  • The stack is popped (ending the function call read).



Dma exercise
DMA Exercise

Suppose that a user program requests the following data transfer:

Read 4096 bytes of data

from file “test”

into array “mybuffer”

Describe in detail all steps involved:

OS activities

DMA controller activities

CPU activities


Summary
Summary

  • Main computer system components:

    • CPU, Memory, I/O Devices

  • Fetch-Decode-Execute-InterruptCheck cycle

  • I/O device controllers

    • Special processors

    • Use local buffers for I/O transfer

  • Software interrupts (system calls, traps) vs. hardware interrupts

  • Interrupt handling steps

  • Interrupt-Driven I/O with DMA


ad