CmSc 12 3Rd Exam PDF
Document Details
Uploaded by CelebratoryKoto
null
Tags
Summary
This document covers fundamental concepts in computer science, including computer architecture, programming languages, and classifications of programming paradigms. Topics like levels of abstraction, generations, and paradigms are explored. The article explains Moore's Law, and the role of the CPU, ALU, and CU.
Full Transcript
Base is determined by the number of digits in the system. The relationship between a digit, its position, and the base is expressed by: Digit x base ^ position Computers count using things called switches. The digits 0 and 1 are called bits. Decimal to binary: Divide by 2 and get the remainder (...
Base is determined by the number of digits in the system. The relationship between a digit, its position, and the base is expressed by: Digit x base ^ position Computers count using things called switches. The digits 0 and 1 are called bits. Decimal to binary: Divide by 2 and get the remainder (either 1 or 0) until ½ Octal_8 = 0-7 Hexadecimal_16 = 0-F Binary to octal: group the bits into 3s (from the radix pt.) Binary to hexa: group the bits into 4s (from the radix pt.) 1 byte = 8 bits 1 nibble = 4 bits 1 pixel = 1int = 4 bytes each byte = 8 bits = 256 values Many processors now represent integers in 32 or 64 bits. 0 is positive 1 is negative 1’s complement or 2’s complement, flip all 0s and 1s ASCII_8 UNICODE_8-16 64 40 @ 65 41 A 90 5A Z 97 61 a 122 7A z Images are 2D arrays. Each cell is a “picture element” (aka pixel). Each cell is a number (usually an int). Central Processing Unit (CPU) heart of the computer circuitry that controls the manipulation of data and execution of instructions These circuits are made of things we call gates which are made of transistors. A modern CPU has millions of transistors in its circuitry. Moore’s Law: The transistor count of integrated circuits doubles every two years. The CPU consists of two main parts: 1. Arithmetic Logic Unit (ALU): Contains the circuitry that performs operations on data (+, -, *, /) 2. Control Unit (CU): Contains the circuitry for coordinating the computer's activities. It fetches the code of all of the instructions in the program. Registers: Temporary storage inside the CPU. Bus: The physical arrangement that connects components. 1. Get one of the values from the main memory to be added from memory and place it in a register. 2. Get the other value to be added from memory and place it in another register. 3. Activate the addition circuitry with the registers used as inputs and use another register to hold the result. 4. Store the result in memory. Inside the CPU are two special purpose registers. 1. Instruction Register: Used to hold the instruction being executed. 2. Program Counter: Contains the address of the next instruction to be executed. Machine Cycle: Fetch - Retrieve the next instruction from memory and increment the PC. Decode - Decode the bit pattern in the Instruction Register. Execute - Perform the instruction in the IR. Machine Instruction: 1. Op-code - This indicates which operation is requested by the instruction. 2. Operand - This provides information about the operation specified by the op-code. Op-codes are given a mnemonic to simplify programming. Together, these mnemonics are called an assembly language. Programming Language: A formal language designed to communicate tasks to a machine. A system for describing computation. Syntax: The form in which programs are written. Semantics: The meaning given to various syntactic constructs. Classifying PL’s 1. Levels of Abstraction: A. Low Level Instructions are simple and machine-like. Uses direct memory access and allocation. e.g. Machine language and Assembly B. High Level Instructions are in expressions and have explicit control flow. Memory access and allocation are done through operations. e.g. C and Java C. Very High Level Fully abstract Fully hidden memory access and has automatic allocation. e.g. Logo, Blockly 2. Generations: 1st: Machine languages and Assembly 2nd: Early 1960s: ALGOL-60, BASIC, COBOL, FORTRAN 3rd: Late 1960s to present: Pascal, C, ADA, Java, Eiffel 4th: Domain specific languages: Visual Basic, SQL, Access, Excel 3. Programming Paradigms: A. Imperative - How is it to be achieved? - To solve a problem, we specify the step-by-step procedure. - Central features: variables, assignment statements, and iteration. - Procedure: the principal building block of the program. (e.g. Pascal and C) - Object Oriented: These are languages that employ the concept of objects. An object is a group of procedures that share a state. These objects are often used to model real-world objects. (e.g. Java, C#, and Modula) B. Declarative - What is to be achieved? - The result is declared but not how to compute for it. - Mainly based from math concepts on logic, theory on functions, and relational calculus. - Logic: Based on a subset of predicate calculus. Axioms and rules are used to deduce new facts. - Functional: These operate only through functions (but different from procedural). Functions are trees of expressions that each return a value. Operating System: A program implemented in either firmware or software which acts as an interface between the user and the computer. Windows, Linux, Mac OS Operating System Purpose 1. It manages the hardware and software resources of the system. 2. It provides a way for applications to deal with hardware. Functions of an Operating System 1. Device Management 2. CPU Management a. Schedules the CPU for many programs. b. Makes sure that the CPU is busy most of the time. Deadlock, Dining Philosopher’s Problem 3. Memory Management Allocates memory to each process for them to execute properly. 4. File System Management a. Manages the organization of secondary storage. b. Provides file abstraction for the convenience of applications and users. 5. Application Interface Provides a consistent way for applications to use the resources of the computer. 6. User Interface Provides a structure to the interaction between a user and the computer. *In the absence of an OS, all the functions previously described will have to be written by the user and incorporated in the user program. 1. 1st Generation (1945-55) Operating systems didn’t exist Users interacted with a machine using machine language. Each user was allocated a time slot to exclusively use a machine. 2. 2nd Generation (1955-65) Simple batch processing 3. 3rd Generation (Late 1960’s) Multiprogramming Since there is only one processor, there can be no true simultaneous execution of different programs. To the user it appears that all programs are executing at the same time. Multiple programs are processed concurrently. 4. 4th Generation (1970s) Multiprogramming + time sharing systems 5. Personal Computers (1980’s - present) Multiprogramming is still a major aspect. Networking User friendliness was most important. 6. Parallel Systems (1985 - present) A system that executes several instructions at the same time. 7. Distributed Systems (1980 - present) A collection of independent computers that appears to the user as a single computer. A collection of independent computers that appears to the user as a single computer. The elements behind a cloud system is “invisible”. 8. Ubiquitous/Pervasive Systems (2000 - present) Operating systems in mobile phones and other small devices.