1 / 26

CSC 2405: Computer Systems II

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

randy
Download Presentation

CSC 2405: Computer Systems II

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 2405: Computer Systems II Spring 2012 Dr. Tom Way

  2. 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

  3. Key to Success • Start early to allow time for debugging.

  4. 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 –

  5. Memory Hierarchy

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

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

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

  9. I/O Operation Example Keyboard c = getchar(); Keyboard Controller CPU

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

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

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

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

  14. 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? ???

  15. 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

  16. 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

  17. DMA Example count = read(fd,buffer,nbytes); Memory Disk drive Disk Controller CPU

  18. Operating System Where Does the OS Fit? Music Player Web Browser Users and User Programs System Calls Interrupts Device Control

  19. 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

  20. 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.

  21. System Call Example (2)

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

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

  24. The Operating System

  25. 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

  26. 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

More Related