cmsc 131 Computer Systems Notes =============================== Based on: Java Software Solutions Foundations of Program Design by Lewis & Loftus. A. Introduction to Computer Systems =================================== 1. Computer System made of two components: ------------------------------------------ a. Hardware - Physical pieces of the computer system. They include cables, printers, monitors, chips, keyboards, and so on. b. Software - Collection of programs. A program is a collection of instructions the computer hardware executes. 2. Hardware Components ---------------------- a. CPU - Central Processing Unit "the brain" - Performs all the fundamental processing in a computer. b. Main Memory - Also known as RAM (Random Access Memory). It is made up of small consecutive memory locations where each has a unique number known as address. Data is stored in these locations. It is usually volatile (i.e., if power is lost information is lost as well). c. Seconday Memory Devices - Hard disk, floppy disk, CD, zip disks, etc. They are usually nonvolatile. d. Input/Output - Devices mouse, monitor, keyboard, and so on. 3. Information Flow ------------------- When a program is to be run, it is loaded from a secondary memory device into main memory. The CPU then process each of the instructions of the program. During the processing of the instructions, information may be displayed, data could be transfered to secondary devices, etc. 4. Software Categories ---------------------- a. Operating System (OS) software - i. Definition: The OS manages computer resources. It provides the necessary infrastructure that allow us to use a computer system. It determines when programs can run, how devices communicate, enforces security protocols, controls access by multiple users, etc. ii. Examples of operating systems - Windows XP, Unix (Linux, Solaris), Mac OS, Pocket PC, Palm, Symbian iii. It is possible, but uncommon to not have any operating system. b. Application software - i. any software other than the operating system. ii. Examples of application software - word processors, web browsers, games. 5. Information representation ----------------------------- a. Two forms to store and manage information: analog and digital. b. Computer systems store information in binary form where information is represented using binary values. In a binary number system only two digits are present: 0 and 1. c. There are different ways to represent a 0 and 1 in a computer system. i. A high voltage in a digital signal could represent a 1; a low voltage 0. ii. A magnetized area could represent a 1; a demagnetized area a 0. iii. A shiny surface reflects light, a pit doesn't (as in a CD or DVD). iv. A piece of paper with or without a hole (ala paper tape). v. Paper Tape Reader Site: http://www.swtpc.com/mholley/OAE80_Reader/OAE80_Index.htm d. Some definitions i. bit - 0 or 1. ii. byte - a collection of 8 bits. iii. word - a collection of bytes, typically 2 or 4. e. N bits give you 2^N combinations. Thus, an N-bit number can represent a number from 0 - 2^N-1 i. Example using two bits: 00 -> 0 01 -> 1 10 -> 2 11 -> 3 f. Units of binary storage KB - 2^10, 1024 bytes MB - 2^20, 1,048,576 bytes GB - 2^30, 1,073,741,824 bytes TB - 2^40, 1,099,511,627,776 bytes g. Some common sizes Main memory: 256 MB common on a PC Pocket PC has 64 MB Secondary memory: Floppy 1.4 MB USB key 32 Meg - 512 MB CD 600 MB DVD 5 GB PC Hard disk 100 GB RAID 10 TB 7. Networks ----------- a. Network - two or more computers that are connected. b. Two types of networks i. LAN (local-area-network) - connects a relatively small number of computers which are relatively close to each other. For example, computers in a building. Examples of LANs: OIT network, WIFI is a LAN ii. WAN (wide-area-network) - connects two or more LAN, usually across long distances. The Internet is a WAN. c. ARPANET - WAN result of an ARPA (Advanced Research Projects Agency) project. Eventually ARPANET became known as Internet. d. TCP/IP - set of protocols that control the movement of messages across the Internet. e. IP address - uniquely identifies a computer in the Internet. An example is 128.8.10.141. f. Internet address (URL) - internet name of a computer (wam.umd.edu for the example above). g. URL - Uniform Resource Locator - It usually specifies five things: http://jazz.cs.umd.edu:8888/oopi?page=5 protocol: http server: jazz.cs.umd.edu (gets mapped to IP address through DNS) port: 8888 file: oopi parameter: page=5 i. World Wide Web - i. Makes exchange of information in the internet easy. ii. Browsers - First one, Mosaic. Others: Netscape, Microsoft's Internet Explorer, Mozilla Firebird, Opera. B. Programming Languages ======================== 1. Levels of programming languages ---------------------------------- a. machine language - instructions are represented by using 0's and 1's. b. assembly language - machine language instructions and memory locations are associated with words (e.g., move AX, BX) c. high-level language - Java, C++, C#. English-like syntax is followed. d. fourth-generation language - 2. Every program you write must eventually be transformed into machine language for the computer to be able to execute it. 3. For the development of programs we need some basic tools: a. Editor - Allows the creation of a file with your program. b. Compiler - Program that translates code in one language to equivalent code in another. (From source code to target code). c. Interpreter - Similar to a compiler but a small part of source code (e.g. statement) is translated and executed before next part is translated. d. IDE - Integrated Development Environment - Combines editor, compiler and other tools into a single application. For example, Eclipse/Dr Java is our IDE. 4. Java - Object-oriented programming language a. Developed in early 1990's by James Gosling at Sun Microsystems. b. It has a rich set of libraries that allow you to create graphics, communicate, over networks, interact with databases, etc. c. Java code is portable. d. Java compiler - Translates Java source code into Java bytecode. e. Java Virtual Machine (JVM) - Reads Java bytecode and executes it. f. Java bytecode is not machine-language. g. Java compiler and interpreter are part of Java Software Development Kit (SDK) also referred to as JDK (Java Development Kit). h. Standard JDK tools are executed on the command line. There is one major competitor to Java - C# and .NET from Microsoft Java => C# JVM => CLR Sun's technologies => .NET Eclipse => Visual Studio Interpreted code => Managed code 5. Syntax and Semantics ----------------------- a. syntax - Rules of grammar and vocabulary of a language. b. semantics - The meaning of something written in the language. c. A program can be syntactically correct but semantically incorrect. d. We want programs that are syntactically and semantically correct. 6. Types of Errors ------------------ a. compile-time b. runtime c. logical