1 / 43

Overzicht Informatica College 5 - September 26

Overzicht Informatica College 5 - September 26. Computer Science an overview EDITION 7 / 8. J. Glenn Brookshear. Computer Science - What is it?. Science of ‘abstraction’:. C H A P T E R 2. Central Processing Unit (CPU). Data Manipulation. CPU and motherboard.

aldon
Download Presentation

Overzicht Informatica College 5 - September 26

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. Overzicht Informatica College 5 - September 26 Computer Science an overview EDITION7 / 8 J. Glenn Brookshear

  2. Computer Science - What is it? • Science of ‘abstraction’:

  3. C H A P T E R2 Central Processing Unit (CPU) Data Manipulation

  4. CPU and motherboard

  5. data manipulation coordination of activities temporary storage The ‘von Neumann Architecture’:CPU and Main Memory connected via a Bus

  6. Central role of the Control Unit • To perform an operation on data stored in main memory, the control unit must • transfer data back and forth between main memory and registers • inform the arithmetic/logic unit which registers hold the input data & which registers should receive the result • activate appropriate arithmetic/logic unit circuitry to perform actual operation

  7. Flexibility of Execution • Early computers were not flexible • operations were built into control unit • Programs now encoded/stored in main memory • known as: stored-program concept • As a consequence, the control unit must also • extract the program from main memory • decode the set of instructions • execute each instruction in turn

  8. Machine Language • To apply the stored-program concept: • CPUs must recognize encoded instructions • Collection of instructions known as: • Instruction set, or • Machine language • Every CPU on the market today has a predefined instruction set • instruction sets often differ among various CPUs

  9. Instruction Repertoire • Machine instructions classified into 3 categories: • (1) Data Transfer • move/copy data from one location to another • typical examples: LOAD, STORE • (2) Arithmetic/Logic • perform actual operations on data • typical examples: AND, OR, XOR, SHIFT, ROTATE • (3) Control • manipulate the execution of a program • typical examples: JUMP, HALT

  10. Composition of Machine Instructions • Machine instructions typically consist of 2 parts: • (1) Op-code (operation code) • indicates which operation (such as STORE, SHIFT, XOR) is requested by the instruction • (2) Operand • provides more information about the operation specified by the op-code (e.g. registers/memory cells to be used)

  11. register holding address of next instruction register holding current instruction Simple Machine Architecture (Appendix C)

  12. Example: decoding instruction 35A7 (App. C)

  13. Adding two values stored in main memory

  14. The Machine Cycle (i.e.: break the operand field into its proper components based on the instruction’s op-code) (and store the instruction in the instruction register) • Continually repeated by Control Unit until HALT • Special case: JUMP (i.e: may change program counter)

  15. Decoding JUMP instruction B258 • Translates as follows: • If contents registers 0 & 2 equal: place 58 in program counter • Otherwise: do nothing

  16. Example: Arithmetic/Logic Instructions • Rotation and Shift: • Move bits within a register to left or right • e.g. for obtaining the mantissa in floating-point values • Shift left = multiply by 2 - Shift right = divide by 2

  17. Opdracht: Ch. 2, Problem 14 R0 = 0 R1 = 1 R3 = 5 R0 = 1 R0 = 2 R0 = 3 R0 = 4 R0 = 5

  18. (10)(13)(16) (11)(14)(17) (12)(15)(18) Opdracht: Ch. 2, Problem 15 (1) (2) (3) (4) (7) (19) (5) (8) (6) (9) (20) => 20 μs

  19. Address Contents 21-22 20 32 23-24 30 B0 25-26 21 20 27-28 C0 00 Opdracht: Ch. 2, Problem 16 R0 = 32 R1 = .. R2 = 12 R0 = 32 R1 = 20 R2 = 12 R0 = .. R1 = .. R2 = .. R0 = .. R1 = .. R2 = 12 Cell 30 = 12 Cell B0 = .. Cell 30 = .. Cell B0 = .. Cell 30 = 12 Cell B0 = 32 Address Contents 20-21 12 20 22-23 32 30 24-25 B0 21 26-27 20 C0 28-29 00 . . 1st: LOAD R2 with value at cell 20 2nd: STORE value in R2 in cell 30 3rd: JUMP to cell 21 4th: LOAD R0 with 32 5th: STORE value in R0 in B0 6th: LOAD R1 with 20 7th: HALT

  20. ‘Von Neumann Architecture’- Problem • A problem of speed…?…! • electric pulses can go no faster than speed of light (approx. 30 cm per nanosecond) • For average machine: • fetch-decode-execute cycle takes several nanosecs. • So: increasing speed becomes problem of scale • small, smaller, … stuck • In other words: there appears to be a speed limit!

  21. ‘Von Neumann Architecture’- Alternatives (1) • One solution: Pipelining • allows steps in the machine cycle to overlap • during execution of one instruction, next is fetched • so: more than one instruction is ‘in the pipe’ • Result: same speed - but higher throughput • Problems with JUMP instructions, of course… • pre-fetching becomes useless • Modern CPUs: • fetch & execute multiple instructions at a time

  22. ‘Von Neumann Architecture’- Alternatives (2) • Other solution: (true) Parallel Processing • performing several tasks at the same time • needs multiple processing units • For example: • several complete PCs connected via fast network • each PC capable of independent execution • …

  23. - Distributed ASCI Supercomputer 2 (Vrije Universiteit, Amsterdam, 2002) (contains 72 1-Ghz Dual Pentium-IIIs) • Parallel Image Processing: CPU 2 CPU 2 CPU 3 CPU 3 CPU 1 CPU 4 CPU 4 CPU 1 CPU 5 CPU 5 2.6: Parallel Processing: Example

  24. Chapter 2 - Data Manipulation: Conclusions • Today’s computers based on ‘von Neumann’ Architecture • CPU connected to main memory via bus • Both program & data stored in main memory • Program execution based on Machine Cycle • fetch - decode - execute • Alternatives to ‘von Neumann’ Architecture: • based on pipelining / true parallel processing

  25. P A R T2 • Operating Systems • Algorithms • Programming Languages • Software Engineering Software • Note: hardware & software are logically equivalent!

  26. P A R T2 Software • Hardware & software logically equivalent: • Any operation performed by software can also be built directly into hardware • Any instruction executed by hardware can also be simulated in software

  27. C H A P T E R3 • Using hardware directly is highly complicated • even at the machine language level Operating Systems • Especially so when multiple users want to perform multiple tasks - all at the same time • abstraction layer: Operating System

  28. Computer System Overview Internet browser Adventure games Airline reservation Application programs Command interpreter Editors Compilers System programs Operating system Machine Language Microprogramming Hardware Physical devices

  29. Bottom-up view:operating system is there to manage all the pieces of a complex system • orderly, controlled management of multiple programs running at the same time • if needed: orderly, controlled management of multiple users at the same time What is an Operating System? • Top-down view: operating system is there to present the user with the equivalent of a ‘virtual machine’ • user should not be annoyed with low level details • OS => high-level abstractions (files, device access, …)

  30. 1955-1965: • Human operator was ‘operating system’ • Advent of ‘batch processing’: The Evolution of Operating Systems (1) • 1945-1955: • User/programmer was ‘operating system’

  31. 1965-1980: • Advent of ‘interactive processing’: The Evolution of Operating Systems (2) • Provide services in a timely manner • ‘real-time processing’ • Multitasking (single-user) & time-sharing (multi-user)

  32. Focus on user-friendliness: • especially: Graphical User Interface (GUI) => The Evolution of Operating Systems (3) • 1980-now: • Operating systems for multi-processor architectures • includes: load balancing

  33. distinction is vague! distinction is vague! Extends capabilities of the OS (e.g.: format, zip, etc…) Software classification

  34. Components of an Operating System • Interface between the OS and users: • shell (command-line, or GUI incl. window manager) • Internal part of OS: • kernel, a.o.: • file manager (coordinates the use of mass storage) • memory manager (coordinates the use of main memory, especially in multitasking and/or multi-user environments) • device drivers (for communication with external device controllers) • scheduler (coordinates the execution of multiple activities) • dispatcher (controls the allocation of time slices to activities) • ...

  35. The Concept of a Process • Important is distinction between a ‘program’ and the ‘activity of executing a program’! • Program is a static set of directions • Activity is dynamic, and its properties may change over time => ‘process’ • Process has state, including: • current position in program (value of the program counter) • values in general-purpose registers & memory cells • So: state is snapshot of machine at certain time

  36. Process Administration & Time-sharing • Process administration handled by • (1) scheduler • keeps track of all processes by maintaining a process table • (2) dispatcher • ensures that scheduled processes are executed by dividing time into slices, and switching CPU’s attention among the processes

  37. Yes: I’m free! Handling Competition Among Processes Process A ? Process B Use flag? No: I’m busy!

  38. Ah, it’s free Yes: I’m free! Problems…! Process A Process B No: I’m busy! two processes are now using the printer at the same time! the problem is that flag-testing and -setting should not be interrupted!

  39. Solutions... • One possibility is to use interrupt enable and interrupt disable instructions • disadvantage: process may remove the possibility of being interrupted altogether • Other approach is to use single test-and-set instruction • always completed before an interrupt can be handled • flag implemented this way is a.k.a.: semaphore

  40. Another problem: Deadlock • Two or more processes are blocked because each is waiting for access to resources allocated to another • task 1: printer yes, disk drive no • task 2: printer no, disk drive yes • Solutions: • deadlock detection and correction • e.g., by forcibly retrieving some allocated resources • deadlock avoidance • e.g.: spooling (make the resource appear as if it can be shared by multiple processes at same time)

  41. Opdracht: Ch. 3, Problem 13[…] If both a compute-bound process and an I/O-bound process are waiting for a time slice, which should be given priority? Why? • I/O operations leave the CPU with nothing else to do because of access delays (see Problem 11) • CPU-wait period can be allotted to other processes • So, I/O bound process should be given priority

  42. Opdracht: Ch. 3, Problem 14Would greater throughput be achieved by a system running two processes if both processes were I/O-bound or if one was I/O-bound and the other was compute-bound? Why? • I/O operations make CPU wait (see Problem 11/13) • CPU-wait period can be allotted to other processes • But… allotting the time to another I/O-bound process is not of much help • This extra process also makes the CPU do nothing... • So, a mix of an I/O-bound process and a compute- bound process generally gives highest throughput • Note: do not forget task-switching overhead

  43. Chapter 3 - Operating Systems: Conclusions • Operating System - ‘glue’ between hardware and applications • Manages and controls multiple applications running at same time • May also service multiple users at same time • Multi-tasking / time-sharing based on processes • Difficulties arise due to competition among multiple processes and deadlocks

More Related