Introduction To Computer Systems PDF
Document Details
Uploaded by IntuitiveSwamp9063
Sphinx University
Tags
Summary
This document provides an introduction to computer systems, covering various aspects such as hardware components, data representation, and the information processing cycle. It also explores the roles of input, process, output, and storage in a computer system.
Full Transcript
A World of information Computers are everywhere: at work, at school, and at home. Mobile computers and mobile devices are small enough to carry. Mobile devices, such as many cell phones, often are classified as computers. Mobile devices are Computers?!!! Computers are a primary m...
A World of information Computers are everywhere: at work, at school, and at home. Mobile computers and mobile devices are small enough to carry. Mobile devices, such as many cell phones, often are classified as computers. Mobile devices are Computers?!!! Computers are a primary means of local and global communication for billions of people. Through computers, society has instant access to information from around the globe. A World of information Banks place ATMs (automated teller machines) (embedded computer) all over the world, so that customers can deposit and withdraw funds anywhere at anytime. Vehicles include onboard navigation systems (embedded computer) that provide directions, call for emergency services, and track the vehicle if it is stolen. People also spend hours of leisure time using a computer. They play games, listen to music or radio broadcasts, ……….. What Is a Computer? A computer is an electronic device, operating under the control of instructions stored in its own memory. A computer can: accept data, process the data according to specified rules, produce results, and store the results for future use Data and Information Computers process data into information. What is Data?! Data is a collection of unprocessed items, which can include text, numbers, images, audio, and video. Information conveys meaning and is useful to people. Computers process several data items to print information in the form of a cash register receipt. Information Processing Cycle Computers process data (input) into information (output). Computers carry out processes using instructions, instructions are the steps that tell the computer how to perform a particular task. A collection of related instructions organized for a common purpose is referred to as software. The series of input, process, output, and storage activities as the information processing cycle. Most computers today communicate with other computers. As a result, communications also has become an essential element of the information processing cycle. The Components of a Computer A computer contains many electric, electronic, and mechanical components known as hardware. These components include: input devices, output devices, a system unit, storage devices, and communications devices. Input Devices An input device is any hardware component that allows you to enter data and instructions into a computer. Five widely used input devices are the keyboard, mouse, microphone, scanner, and Web cam. What is the job of each previous mentioned device?!!!! Output Devices An output device is any hardware component that conveys information to one or more people. Three commonly used output devices are: a printer, a monitor, and speakers System Unit The system unit is a case that contains the electronic components of the computer that are used to process data. The circuitry of the system unit usually is part of or is connected to a circuit board called the motherboard Two main components on the motherboard are: processor and memory. The processor, also called a CPU (central processing unit), is the electronic component that interprets and carries out the basic instructions that operate the computer. Memory consists of electronic components that store instructions waiting to be executed and data needed by those instructions. The computer memory is volatile, which means its contents are erased when the computer is shut off. Storage Devices Storage holds data, instructions, and information for future use. For example, computers can store hundreds or millions of customer names and addresses. Storage holds these items permanently. Examples of storage media are USB flash drives, hard disks, optical discs, and memory cards. A storage device records (writes) and/or retrieves (reads) items to and from storage media. A USB flash drive is a portable storage device that is small and lightweight enough to be transported on a keychain or in a pocket. A hard disk provides much greater storage capacity than a USB flash drive. Hard disks are enclosed in an airtight, sealed case. Although some are portable, most are housed inside the system unit Portable hard disks are either external or removable. Communications Devices A communications device is a hardware component that enables a computer to: send (transmit) and receive data, instructions, and information to and from: one or more computers or mobile devices. A widely used communications device is a modem. Communications occur over cables, telephone lines, cellular radio networks, satellites, and other transmission media. Some transmission media, such as satellites and cellular radio networks, are wireless, which means they have no physical lines or wires. Computer Characteristics Speed: When data, instructions, and information flow along electronic circuits in a computer, they travel at incredibly fast speeds. Reliability: The electronic components in modern computers are dependable and reliable because they rarely break or fail. Consistency: Given the same input and processes, a computer will produce the same results — consistently. Storage: A computer can transfer data quickly from storage to memory, process it, and then store it again for future use. Communications: Most computers today can communicate with other computers, often wirelessly. Computers with this capability can share any of the four information processing cycle operations — input, process, output, and storage — with another computer or a user. Computers Misuse Health Risks: Prolonged or improper computer use can lead to injuries or disorders of the hands, wrists, elbows, eyes, neck, and back. Computer users can protect themselves from these health risks through proper workplace design, good posture while at the computer, and appropriately spaced work breaks. Two behavioral health risks are computer addiction and technology overload. Violation of Privacy: Nearly every life event is stored in a computer somewhere... in medical records, credit reports,… Individuals could have find their privacy violated and identities stolen Public Safety: Adults, teens, and children around the world are using computers to share publicly their photos, videos, journals, music, and other personal information. Do not share information that would allow others to identify or locate you and do not disclose identification numbers, passwords. Networks and the Internet A network is a collection of computers and devices connected together, often wirelessly, via communications devices and transmission media. Networks allow computers to share resources, such as hardware, software, data, and information. Sharing resources saves time and money. The server controls access to the resources on a network. The other computers on the network, each called a client or workstation, request resources from the server What major differences between the server and client computers? Home networks usually are small, existing within a single structure. Business and school networks can be small, such as in a room or building, or widespread, connecting computers and devices across a city, country, or the globe. The world’s largest computer network is the Internet! The Internet The Internet is a worldwide collection of networks that connects millions of businesses, government agencies, educational institutions, and individuals. People around the world use the Internet daily for a variety of reasons: Communicate with and meet other people Conduct research and access a wealth of information and news Shop for goods and services Bank and invest Participate in online training Engage in entertaining activities, such as planning vacations, playing online games, listening to music, watching or editing videos. Download music and videos Share information, photos, and videos Access and interact with Web applications With instant messaging, you can have a live conversation with another connected user. In a chat room, you can communicate with multiple users at the same time — much like a group discussion. You also can use the Internet to make a telephone call The Web, short for World Wide Web, is one of the more popular services on the Internet. The Web contains billions of documents called Web pages. Web pages often have built-in connections, or links, to other documents, graphics, other Web pages, or Web sites. A Web site is a collection of related Web pages. A blog is an informal Web site consisting of timestamped articles in a diary or journal format, usually listed in reverse chronological order. A Web application is a Web site that allows users to access and interact with software from any computer or device that is connected to the Internet. Ex: Web applications include those that allow you to send and receive e-mail messages, prepare your taxes, organize digital photos, create documents, and play games. Thank you! Lecture 3: Computer Software OBJECTIVE Learn the types of software and the purpose of each type. Understand the function of the operating system. Recognize the types of the operating system. Differentiate between the generations of programming languages. COMPUTER SOFTWARE Programs that execute on hardware Program: collection of instructions to carry out in order to complete some task Computer software can be broadly classified into: System Software (such as Operating system) Application software (such as web browser TYPE OF SOFTWARE Application software is used by the users to perform specific tasks System software provides the basic functions that are performed by the computer. SYSTEM SOFTWARE Provides basic functionality to computer, Controls computer hardware, Acts as an interface between user, application software and computer hardware Categorized based on Function: Management: BIOS, OS, Device Driver, System Utilities Development: Compiler, Interpreter, Linker. OPERATING SYSTEM Special program loaded automatically when computers start. Designed to allow application software and users to interact with hardware without having to learn all the details of how the hardware works. Managing and controlling different resources of computer hardware. Operating system is a large and complex software consisting of several components. Examples: Windows, Android, Linux, and UNIX. OPERATING SYSTEM Main functions of the operating system are: Process Management Memory Management File Management Device Management Protection and Security User Interface or Command Interpreter OPERATING SYSTEM Command Line Interface (Dos,Unix) Graphical User Interface (GUI) OPERATING SYSTEM Single-user, single-task (e.g. Palm OS , MS-DOS) Single-user, multi-tasking (e.g. MS-Windows) Multi-user, Multi-tasking (e.g. UNIX) Multiprocessing (e.g. UNIX) Real-time operating system (RTOS): for real- time applications such as scientific instruments and industrial systems (e.g. LynxOS) Embedded: used in appliances like microwaves, washing machines, traffic control systems SYSTEM SOFTWARE Device Driver System Utilities Anti-virus Data and Disk Compression Cryptographic Disk Cleaners Backup System Profiling Network Managers PROGRAMMING LANGUAGES A Programming Language consists of a set of vocabulary and grammatical rules, to express the computations and tasks that the computer has to perform. Programming languages fall into three categories: Machine Language Assembly Language High-level Language (HLL) TRANSLATOR SOFTWARE Assembler Compiler: Translates an entire program at once Compiled programs are faster to execute e.g. C++, and Java Interpreter: Translates one program line at a time Interpreted programs are easier to debug e.g. Python, and some versions of BASIC HIERARCHYOF PROGRAM EXECUTION Other object code Source Object Executable Compiler Linker Code Code Code High level Language Machine Language Machine Language APPLICATION SOFTWARE Programs that user use, Program are designed for a relatively specific subject purpose or General purpose General-Purpose applications Specialized application GENERAL-PURPOSE APPLICATIONS General purpose or “off-the-shelf” programs such as Word Processing Image Processing Spreadsheet Suite of Software CAD/CAM Geographic Information Systems Web Browser SPECIALIZED APPLICATION Problem-SpecificPrograms,narrowfocuson specificdisciplinesand occupations Programthatauserwritestosolveaspecificproblem SOFTWARE ACQUISITION Retail Software is off-the-shelf software sold in retail stores. OEM Software stands for “Original Equipment Manufacturer” software. It refers to software which is sold and bundled with hardware. Demo Software is designed to demonstrate what a purchased version of the software can do and provides a restricted set of features. Shareware is a program that the user can try for free, for a specified period, as defined in the license. Freeware is software that is free for personal use. Public Domain Software is free software. Unlike freeware, public domain software does not have a copyright owner or license restrictions. Open-Source Software is software whose source code is availableand can be customized and altered within the specified guidelines laid THANKS Introduction to Computer Systems Data Representation Outlines Recognize the number systems. Learn the conversion from a number system to another one. Understand binary arithmetic. Floating point binary data representation. Text data representation. Data Representation Data can be in the form of numbers, text, audio, image, video or a combination of these forms which is called multimedia. Any form of data must be represented by symbols 0 and 1 to be stored in or processed by computers. Encoding: The way the data could be represented into 0 and 1 Number System A number system in base (radix) r uses unique symbols for r digits. One or more digits are combined to get a number The digits of a number have two kinds of values: o Digit value o Position value The number is calculated as the sum of Digit * baseposition of each of the digits A number in a particular base is written as: (number)base Number of values could be represented in n digit is rn Number System Example: decimal which has base 10 has 10 digits values (0-9) X = (5432)10 X = 5*103 + 4*102 + 3*101 + 2*100 = 5*1000 + 4*100 + 3*10 + 2*1 =5432 Number of values could be represented in 4 digit = 104 Number Systems In computers, we are concerned with four kinds of number systems: Number Systems Example Decimal Number System: (512.49)10 (512.49)10 = 5x102 + 1x101 + 2x100 + 4x10-1 + 9x10-2 (512.49)10 = 5x100 + 1x10 + 2X1 +4x.1 + 9x.01 (512.49)10 = 512.49 Number Systems Example Octal Number System: (456.41)8 (456.41)8 = 4x82 + 5x81 + 6x80 + 4x8-1 + 1x8-2 (456.41)8 = 4*64 + 5*8 + 6*1 + 4/8 + 1/64 (456.41)8 = 302.515625 Number Systems Example Hexadecimal Number System: (1FA.4C)16 (1FA.4C)16 = 1x162 + 15x161 + 10x160 + 4x16-1 + 12x16-2 (1FA.4C)16 = 1*256 +15*16 +10*1+4/16 + 12/256 (1FA.4C)16 = 506.296875 Number Systems Example Binary Number System: (1101.01)2 (1101.01)2 = 1x23 + 1x22 + 0x21 + 1x20 + 0x2-1 + 1x2-2 (1101.01)2 = 1*8 +1*4 + 0*2 + 1*1 + 0/2 + + 1/4 (1101.01)2 = 13.25 Converting Decimal Integer to Binary, Octal, Hexadecimal A decimal integer is converted to any other base, by using the division operation (integer division) by the base of the new number system. Example: Convert (25)10 to binary, octal and Hexadecimal. Converting Decimal Integer to Binary Number base of Reminder (Quotient) new system 25 ÷2 1 LSB 12 ÷2 0 6 ÷2 0 3 ÷2 1 1 ÷2 1 MSB 0 End when last result =0 (25)10 = (11001)2 (11001)2 = 1x24 + 1x23 + 1x20 Converting Decimal Integer to Octal Number base of new Reminder (Quotient) system 25 ÷8 1 LSB 3 ÷8 3 MSB 0 End when last result =0 (25)10 = (31)8 (31)8 = 3x81 + 1x80 Converting Decimal Integer to Hexadecimal Number base of new Reminder (Quotient) system 25 ÷16 9 LSB 1 ÷16 1 MSB 0 End when last result =0 (25)10 = (19)16 (19)16 = 1x161 + 9x160 Converting Decimal to Binary, Octal, Hexadecimal Example: convert 234 to binary , octal ,hexadecimal 234 = (11101010)2 234 = (352)8 234 = (EA)16 Converting Binary to Octal and Hexadecimal Convert the binary number 1110101100110to Hexadecimal convert to (1110101100110)2 decimal (1110101100110)2 = 212 +211 +210 +28 +26 +25 +22 +21 = 7526 Number base of Reminder convert 7526 to hexadecimal (Quotient) new system 7526 ÷16 6 470 ÷16 6 7526 = (1D66)16 29 ÷16 13 (1110101100110)2= (1D66)16 1 ÷16 1 0 Converting Binary to Octal and Hexadecimal A binary number can be converted into octal or hexadecimal number using a shortcut method. o An octal digit can be represented as a combination of 3 bits, since 23 = 8. o A hexadecimal digit can be represented as a combination of 4 bits, since 24 = 16. Example: Convert the binary number 1110101100110 to hexadecimal and octal Note: The conversion of a number from octal and hexadecimal to binary uses the inverse of the steps defined for the conversion of binary to octal and hexadecimal. Converting Binary to Hexadecimal Example: Convert the binary number 1110101100110to hexadecimal (1110101100110)2 = 1 - 1101 - 0110 - 0110 =1- D - 6 -6 = (1D66)16 Converting Binary to Octal Example: Convert the binary number 1110101100110to octal. (1110101100110)2 = 1 - 110 - 101 - 100 - 110 =1 - 6 -5 -4 -6 = (16546)8 Binary Arithmetic - Addition Two bits 0+0 sum 0 Carry 0 (No carry) 0+1 1 0 (No carry) 1+0 1 0 (No carry) 1+1 0 1 (carry) Three bits sum Carry 0+0+0 0 0 (No carry) 0+0+1 1 0 (No carry) 0+1+0 1 0 (No carry) 0+1+1 0 1 1+0+0 1 0 (No carry) 1+0+1 0 1 1+1+0 0 1 1+1+1 1 1 Binary Arithmetic (Subtraction) Two bits Difference Borrow 0-0 0 No borrow 0-1 1 1 1-0 1 No borrow 1-1 0 No borrow Characters Coding Schemes Data such as alphabets, digits 0−9, and symbols is represented in a standard code. A combination of bits represents a unique symbol in the data. The binary coding schemes that are most commonly used are: Extended Binary Coded Decimal Interchange Code (EBCDIC) 8-bits , mainframe American Standard Code for Information Interchange (ASCII) Unicode Compatible with ASCII-8, (16-bits or 32-bits) Some characters and their corresponding ASCII patterns Character Bit pattern Byte # Character Bit pattern Byte # A 1000001 65 < 0111100 60 B 1000010 66. 0101110 46 C 1000011 67 : 0111010 58 a 1100001 97 $ 0100100 36 b 1100010 98 \ 1011100 92 O 1101111 111 0 0110000 48 P 1110000 112 1 0110001 49 Q 1110001 113 2 0110010 50 R 1110010 114 9 0111001 57 X 1111000 120 ) 0101001 41 Y 1111001 121 > 0111110 62 Z 1111010 122 HT(Tab) 0001001 9 Introduction to Computer Systems Module 5: Algorithm Development Dr Islam Alkabbany Objectives Recognize the program development life cycle. Select appropriate computer-based methods for Modeling and analyzing problems. Differentiate between algorithm, pseudo code, and flowchart. Software development life cycle Software development life cycle 1- Planning (Problem Definition) In this phase, we define the problem statement and we decide the boundaries of the problem. In this phase we need to understand the problem statement, what is our requirement, what should be the output of the problem solution. These are defined in this first phase of the program development life cycle. Software development life cycle 2- Problem Analysis Precisely define the problem to be solved, and write program specifications – descriptions of the program’s inputs, processing, outputs, and user interface. Software development life cycle 3- Design Develop a detailed logic plan using a tool such as pseudo-code, flowcharts, object structure diagrams, or event diagrams to group the program’s activities into modules; devise a method of solution or algorithm for each module and test the solution algorithms. Software development life cycle 4- Implementation Translate the design into an application using a programming language or application development tool by creating the user interface and writing code; include internal documentation – comments and remarks within the code that explain the purpose of code statements. Software development life cycle 5- Testing and Integration Test the program, finding and correcting errors (debugging) until it is error-free and contains enough safeguards to ensure the desired results. Software development life cycle 6- Maintenance Provide education and support to end- users; correct any unanticipated errors that emerge and identify user-requested modifications (enhancements). Once errors or enhancements are identified, the program development life cycle begins again at Step 1. Software development life cycle Retirement The unofficial eighth step of the SDLC is retirement. No software lives forever. As it ages, stakeholders will find problems that need to be corrected, usually in a new version of the code. Or, they will decide to create an entirely new replacement application. Software development life cycle Documentation The document is to put together all of the materials that have been generated throughout the PDLC process. All of the flowcharts, messages, algorithms, lines of code, and the user manuals are part of this documentation. Internal documentation: is used by other programmers to help them know why you did something a certain way or tell them how you wrote a program. External documentation: includes user manuals and anything that is not the actual code or is part of the listing. This should also include materials that are placed on a website such as FAQs (frequently asked questions) and help areas. Algorithm Algorithm is an ordered sequence of finite, well defined, unambiguous instructions for completing a task. The term Algorithm derives from the name of Muhammad ibn Musa al’Khwarizmi Algorithm (Example) Problem: Find the area of a circle of radius r. Inputs to the algorithm Radius r of the circle. Expected output: Area of the circle Algorithm (Example) Algorithm: Step1: Read/input the Radius r of the circle Step2: Compute Area = 3.14*r*r Step3: Print Area Algorithm (Example) Algorithm to find the greatest among three numbers ALGORITHM 1. Step 1: Read the three numbers A, B, C. Step 2: Compare A and B. If A is greater perform step 3 else perform step 4. Step 3: Compare A and C. If A is greater, output “A is greatest” else output “C is greatest”. Step 4: Compare B and C. If B is greater, output “B is greatest” else output “C is greatest”. Algorithm (Example) Algorithm to find the greatest among three numbers ALGORITHM 2. Step 1: Read the three numbers A, B, C. Step 2: Compare A and B. If A is greater, store A in MAX, else store B in MAX. Step 3: Compare MAX and C. If MAX is greater, output “MAX is greatest” else output “C is greatest”. Algorithm ( Control structure) Sequential instructions are executed in linear order Step1: Read/input the Radius r of the circle Step2: Compute Area = 3.14*r*r Step3: Print Area Algorithm ( Control structure) Selection (branch or conditional): it asks a true/false question and then selects the next instruction based on the answer instructions are executed in linear order Step 1: Read the three numbers A, B, C. Step 2: Compare A and B. If A is greater perform step 3 else perform step 4. Step 3: Compare A and C. If A is greater, output “A is greatest” else output “C is greatest”. Step 4: Compare B and C. If B is greater, output “B is greatest” else output “C is greatest”. Algorithm ( Control structure) Iterative (loop) it repeats the execution of a block of instructions Step1: Read/input the Radius r of the circle Step2: Compute Area = 3.14*r*r Step3: Print Area Step4: Goto step 1 Flowchart is a diagrammatic representation of the logic for solving a task / diagrammatic representation of the Algorithm. Flowchart (Control Structures) Flowchart (Example) 1. Flowchart of a program that computes product of any two numbers Flowchart (Example) 2. Flowchart of a program that computes three numbers and finds the maximum Flowchart (Example) 3. Flowchart of a program that finds the sum of first 100 integers Pseudo Code Pseudo code consists of short, readable and formally-styled English language used for explaining an algorithm. In a pseudo code, some terms are commonly used to represent the various actions. For example: – for inputting data the terms may be (INPUT, GET, READ) – for outputting data (OUTPUT, PRINT, DISPLAY) – for calculations (COMPUTE, CALCULATE) – for incrementing (INCREMENT), initialization (INITIALIZE) Pseudo Code (Control Structures) Pseudo Code Pseudo Code Software development System development life System development is the process of creating software or an information system. ◦ System analysis ◦ System design ◦ System development ◦ Maintenance System development life There are different approaches for creating a software waterfall Agile method Waterfall Each phase is occurred separately one after another Waterfall The advantage of waterfall model is good system design and full system documentation. However, it takes long time to develop the system. Waterfall model is suitable for large scale systems or systems that develop in different sites Agile method adopts incremental development idea The system is divided into small functionalities There is a sequence of development rounds The main advantage of agile method is rapid development The first system usually contains a small set of high priority functions Agile method Types of applications There are different types of applications such as: ◦ desktop application ◦ web application ◦ mobile application. Different types of application have different tools for implementation Desktop application is a computer application that can be installed on a single computer Sometimes desktop application can be used on a local network The word processor or calculator application is an example for typical desktop applications. Many programming languages can be used to develop desktop applications such as C, C++, Basic, and Java. Web application Is a computer program that developed to be used through the Internet. Web applications are designed to run in client-server architecture. installed on the server side. The users use the application in client side through web browser. Web mail is an example of web application. Different programming language can be used to develop web based application such HTML, Java Script, and PHP. Web application Server The Internet Client Client Client Client-server over internet Mobile application programs that developed to be installed on mobile device such as smart phone or tablet These devices have special characteristics such as limited computing power and limited power supply. Mobile games and all applications on your mobile are example for mobile applications. Development phases System analysis in which the current situation is explored and the requirements of the desired systems are defined. The design phase concerns with how to convert the requirements to a system. The third phase is implementation of the design in which the design is implemented in a programming language Testing and maintaining System analysis discover the system environment and define the requirements of the system defining the requirements is a critical phase in development life cycle The errors in system analysis lead to refusing the developed system from the end user. errors n this phase are very costly System analysis The final requirements should be : ◦ complete ◦ valid. system analyst should collect all requirements of the system Valid requirements mean there is no contradiction between requirements System analysis activities Design process Design is a process to transform user requirements into some suitable form, which helps the programmer in software coding and implementation. aims to facilitate converting user requirements into an application. The design phase is concerned with planning the architecture of the system. The design process activities Architectural design Abstract specification Interface design Component design Data structure design Algorithm design Architecture design Architecture design is abstract design in which the main components of the system and relations between these components are determined. Normally, the designer uses sketch to draw architecture design. The input is a set of requirements. requirements are grouped into coherent sets. Each group of requirements can be implemented and provided by a subsystem. High-level Design The high-level design breaks the ‘single entity-multiple component’ concept of architectural design into less abstracted view of sub-systems and modules and depicts their interaction with each other. High-level design focuses on how the system along with all of its components can be implemented in forms of modules. It recognizes modular structure of each sub- system and their relation and interaction among each other. Detailed Design Detailed design deals with the implementation part of what is seen as a system and its sub-systems in the previous two designs. It is more detailed towards modules and their implementations. It defines logical structure of each module and their interfaces to communicate with other modules. Implementation and testing converting system design into a real application Using programming language Testing is important to ensure that the system is working properly Programming Program is a set of instructions written in a programming language. Programming means writing a computer program that can be run and executed in an electronic device. Programming language A programming language is a way to communicate with computers. Using programming language you can write instructions that computers understand and execute. 10100101 00101101 Computers understand 11110101 10001010 only machine language. 01111010 10011101 11000111 00010011 This was very complex … and tedious job binary code Compilers Programmers can write a program easily using high level language Compiler is a computer program that translates from high level language into low level language or machine code. For each programming language there is a compiler compilers help programmer to write error free code Integrated Development Environment (IDE) is a development environment that integrate many tools to help programmers to develop easily IDE integrates compiler, linker, debugger, and editor. ◦ Editor is a program that used by programmer to write the program ◦ The debugger is a program that enable programmer to trace the code and execute it step by step ◦ Linker combined the translated code and other libraries used in the code and generate executable file. IDE example Object oriented programming (OOP) The idea of this programming paradigm is to divide the problem domain into objects The object can contain data and code. class is a definition of a specific type of objects. object is an instance of a class represent a real entity in the environment Example Student name address GPA phone courses enroll(course) calculate_GPA() get_data() Std1 Std2 Mohamed Ali Hassan Omer 12 Tahrir st 43 Horria st, Assiut 3.4 3.7 02-36985858 088-7412583 [math accounting OS] [math accounting IS] Advantages of OOP code will be more organized. Each set of related functionalities are grouped into an object. This facilitate changing or updating code Other objects will not be affected when a specific object is changed. Moreover, using of classes help for reusing. If you design a generic class, you can use it multiple times in different subprograms. Example Person name phone addre ss Student Employee level department GPA salary Graduate_Student thesis_title supervisor class hierarchy sample OOP The steps in object oriented programming: 1. determining the class in the system domain. 2. Determining attributes and functions of each class 3. relations between those classes should be determined 4. writing code. Object oriented programming facilitates dividing task between team members. Languages support OOP Many of widely used programming languages support object oriented programming paradigm such as: ◦ C++, ◦ Java, ◦ Python. Testing Testing is an important phase in system development. Testing means to ensure that the developed software is working properly. The test should be done in a structured way according to a predefined test plan. Test plan should contain test cases and expected results. not only normal behavior should be tested. check all possible input and all possible output Good testing results does not mean the system is error free. Unit test This is a kind of test applied to a single unit of the system. This unit may be a required function such as calculating student GPA. The tester should design test cases to find both programming errors and logical errors. Programming error is bugs in the developed unit that causes exception In logical error the system work well but return unexpected results. Integration test The tested units are integrated together to make the hall system. The constructed system should be test again. Some errors come from integration of different parts. This test is important to ensure that all parts of the system are working coherently. Thanks Operating System An overview What is Operating system An operating system (OS) is a crucial piece of software that acts as an intermediary between computer hardware and the various applications running on a computer. It provides a set of essential services that allow users and applications to interact with the computer's hardware in a convenient and efficient manner.. Basic Functions of an Operating System Process Management: The OS manages processes, which are executing instances of a program. It allocates resources, schedules tasks, and ensures that processes run smoothly without interfering with each other. Memory Management Operating systems are responsible for managing a computer's memory, ensuring that programs and data are loaded into the appropriate memory locations and that processes do not access each other's memory space. Basic Functions of an Operating System File System Management: The OS provides a file system that organizes and manages data on storage devices. It enables users and applications to create, read, write, and delete files. Device Management: Operating systems handle communication with hardware devices such as printers, disk drives, and input devices. They provide a consistent interface for applications to interact with various hardware components. User Interface: OS provides a user interface (UI) through which users can interact with the computer. Key Components of an Operating System Kernel The core of the operating system that manages hardware resources and provides essential services. Device Drivers: Software that facilitates communication between the operating system and hardware devices. File System: Manages the organization and storage of data on storage devices. Key Components of an Operating System Shell/ User interface(UI): The user interface that allows users to interact with the operating system. It can be a command-line shell or a graphical shell. oCommand-Line Interface (CLI):Users interact with the computer by typing text commands into a terminal. Efficient for experienced users, scripting, and automation. Used for recovery process when GUI cannot be loaded (Command Prompt in Windows, Terminal in Linux and macOS) oGraphical User Interface (GUI):Users interact with Key the computer through graphical elements such as icons, buttons, and windows. User-friendly, visually Components intuitive. (Windows Explorer, macOS Finder, Linux of an desktop environments (e.g., GNOME, KDE).) Operating oVoice User Interface (VUI): Users interact with the System system using voice commands. Hands-free operation, accessibility. Virtual assistants (e.g., Siri, Alexa). Types of Operating Systems 1. Single-User, Single-Tasking: These operating systems support one user and one task at a time. Examples include early versions of MS-DOS. 2. Single-User, Multi-Tasking: Allows a single user to run multiple programs simultaneously. Modern desktop operating systems like most versions of Windows, macOS, and Linux fall into this category. Types of Operating Systems 3. Multi-User: Designed to support multiple users simultaneously. Examples include Unix and mainframe operating systems. 4. Real-Time Operating System (RTOS): Designed for systems that require immediate and predictable responses to events. Commonly used in embedded systems and control systems. Evolution of Operating Systems Batch Processing Systems: Early computers used batch processing, where users submitted jobs on punched cards, and the computer processed them in sequence. Time-Sharing Systems: Introduced the concept of sharing computer resources among multiple users simultaneously, providing each user with a small time slice. Evolution of Operating Systems Personal Computer Operating Systems: With the advent of personal computers, operating systems like MS-DOS, Windows, and macOS emerged, bringing computing to a broader audience. Networked Systems: Operating systems evolved to support networking, enabling computers to communicate and share resources over networks OS boot OS Boot : The action of initiating or restarting a computer, causing it to begin its startup sequence. During the boot process, the computer's hardware components are initialized, and the operating system is loaded into memory, allowing the computer to become operational. The process of booting an operating system involves several steps, from the moment you turn on your computer to the point where the operating system is fully loaded and ready for user interaction OS boot steps 1 Power-On Self-Test (POST): When you turn on your computer, the system hardware (CPU, RAM, storage, etc.) undergoes a self-check known as POST. POST ensures that essential hardware components are functioning correctly. If any issues are detected during POST, the system may produce error messages or beeping sounds. OS boot steps 2- BIOS/UEFI Initialization: Once POST is successfully completed, the Basic Input/Output System (BIOS) or Unified Extensible Firmware Interface (UEFI) takes control. BIOS/UEFI is firmware stored on the motherboard (ROM/Flash memory) and provides low-level communication between the operating system and hardware. It initializes essential hardware components and identifies the boot device (usually the hard drive or SSD). OS boot steps 3- Boot Loader Execution: The BIOS/UEFI transfers control to the boot loader, a small program located on the boot device. The boot loader's role is to load the operating system kernel into memory. On systems using the traditional BIOS, the Master Boot Record (MBR) contains the boot loader. In UEFI systems, the EFI System Partition (ESP) holds the boot loader. OS boot steps 4- Kernel Loading: The boot loader loads the operating system kernel into memory. The kernel is the core part of the operating system responsible for managing system resources and providing essential services. Once the kernel is loaded, it takes control of the system. OS boot steps 5- Init Process The kernel initializes the essential system processes. 6- User Space Initialization: User space processes and services are started. The user space is where applications and user interfaces run.. OS boot steps 7- Login Prompt or Graphical User Interface (GUI):boot process may conclude with a login prompt. Depend on OS it may load GUI also 8- User Interaction: The operating system is ready for user interaction. Cold boot vs Warm boot Cold Boot: A cold boot refers to the process of starting a computer from a completely powered-off state. During a cold boot, the computer's power is turned off, and when it is restarted, it goes through the entire boot sequence. The system initializes hardware components from scratch. Memory is typically cleared, and the operating system and applications load into the computer's RAM (Random Access Memory). This type of boot takes more time compared to a hot boot. Cold boot vs Warm boot Warm Boot: warm boot involves restarting a computer without fully powering it off. The operating system is reinitialized without going through the entire boot process. The system initializes hardware components from scratch. The system retains the current state of hardware components and may not reinitialize them. Memory contents are preserved, avoiding the need to reload the operating system and applications into RAM. Warm boots are generally faster than cold boots because certain processes are skipped. Hibernate When a computer is hibernated, the contents of its RAM (random access memory), which stores the currently running programs and data, are saved to a specific file on the hard drive or SSD. The computer then shuts down completely, consuming minimal power. When the computer is powered on again, it reads the hibernation file and restores the system to its pre-hibernation state. Hibernation allows for a quick startup because the system does not need to go through the entire boot process. Types of boot processes 1 BIOS Boot Process: Firmware: Basic Input/Output System (BIOS) Boot Loader: Master Boot Record (MBR) contains the boot loader. Common on: Older computers and systems running legacy operating systems. Types of boot processes 2- UEFI Boot Process: Firmware: Unified Extensible Firmware Interface (UEFI) Boot Loader: Stored in the EFI System Partition (ESP). UEFI supports the use of the GUID Partition Table (GPT). Common on: Modern computers, especially those with newer versions of Windows, Linux, and macOS. Types of boot processes 3- Network Boot (PXE Boot): Some systems can boot from a network using Preboot Execution Environment (PXE). The computer fetches the boot files from a server on the network. Common in enterprise environments for centralized OS deployment. Types of boot processes 4- Fast Boot/Hybrid Boot: Some modern operating systems, like Windows 8 and later, feature a fast boot or hybrid boot process. This involves a combination of cold boot (traditional startup) and hibernation. The OS saves the system state to disk during shutdown, allowing for faster startup times. Types of boot processes 5- Secure Boot: A security feature in UEFI that ensures only signed and trusted bootloaders and OS components are allowed to run during the boot process. Designed to prevent the loading of malicious or unauthorized code during boot. Types of boot processes 6- Boot from External Media: The OS can be booted from external storage devices like USB drives or external hard drives. Useful for troubleshooting, installing a new OS, or running a portable operating system. Process management & Memory Management Process Scheduling: Definition: Process scheduling is the mechanism by which the operating system manages the execution of processes in a system. Objective: Efficiently utilize the CPU and ensure fair execution for all processes Why Process Scheduling Resource Allocation: The CPU is a finite resource, and effective scheduling ensures optimal utilization. Responsiveness: Users expect quick responses. Scheduling influences how responsive a system feels. Throughput: Maximizing the number of processes completed per unit time. Process statues Process statues 1. New: 1. This is the initial state when a process is first created. 2. In this state, the process is being set up and initialized. 2. Ready: 1. After initialization, the process moves to the ready state. 2. It is waiting to be assigned to a processor for execution. 3. Running: 1. The process moves to the running state when it is being executed on a CPU. 2. In a multiprogramming environment, multiple processes may be in the running state simultaneously on different processors. Process statues 4. Waiting/blocked : 1. A process enters the blocked state when it cannot proceed until some event occurs. 2. This event could be the completion of an I/O operation, the availability of a resource, etc. 5. Terminated: 1. The process moves to the terminated state when it has finished its execution. 2. At this point, the operating system releases the resources associated with the process. 6. Suspended (optional): 1. Some systems have an additional "suspended" state. 2. A process may be temporarily moved to this state to free up resources for other processes. CPU dispatcher Component of an operating system responsible for making decisions about the execution of processes on the CPU. it is responsible for deciding whether the currently running process should continue running and, if not, which process from ready queue should run next. CPU dispatcher 1. Process Selection: 1. The dispatcher selects the next process from the pool of ready processes to be run 2. Context Switching: 1. If the selected process is different from the one currently running on the CPU, the dispatcher performs a context switch. This involves saving the context (state) of the currently running process and loading the context of the new process. 3. CPU Allocation: 1. The dispatcher allocates the CPU to the selected process, allowing it to execute its instructions. CPU Scheduling Algorithms(Process Selection) First-Come, First-Served (FCFS) Shortest Job First (SJF) Round Robin (RR) Priority Scheduling Multilevel Queue Scheduling CPU Scheduling Algorithms First-Come, First-Served Possibly the most straightforward approach to scheduling processes is to maintain a FIFO (first-in, first-out) run queue. New processes go to the end of the queue. When the scheduler needs to run a process, it picks the process that is at the head of the queue Advantage: Simple and easy to understand. It is also intuitively fair Disadvantage: May suffer from the "convoy effect" where short processes get stuck behind long ones. CPU Scheduling Algorithms(Process Selection) Shortest Job First (SJF) Shortest job will be scheduled first. The biggest problem with sorting processes this way is that we’re trying to optimize our schedule using data that we don’t even have! We don’t know what the CPU burst time will be for a process when it’s next run Advantage: Minimize the total processing time. Disadvantages: May lead to "starvation" for longer processes. In most scenarios it is impossible to estimate the duration of process CPU Scheduling Algorithms(Process Selection) Round Robin (RR) Round robin scheduling is a preemptive version of first-come, first- served scheduling. Processes are dispatched in a first-in-first-out sequence, but each process is allowed to run for only a limited amount of time. This time interval is known as a time-slice or quantum. Advantage: Round robin scheduling is fair in that every process gets an equal share of the CPU Disadvantage: fairness depends on time slice size. Giving every process an equal share of the CPU is not always a good idea CPU Scheduling Algorithms(Process Selection) Priority Scheduling Each process is assigned a priority (just a number). Of all processes ready to run, the one with the highest priority gets to run next Advantage: priority scheduling provides a good mechanism where the relative importance of each process may be precisely defined Disadvantage: If high priority processes use up a lot of CPU time, lower priority processes may starve and be postponed indefinitely, leading to starvation CPU Scheduling Algorithms(Process Selection) Priority Scheduling Process aging: The scheduler keep track of low priority processes that do not get a chance to run and increase their priority so that eventually the priority will be high enough so that the processes will get scheduled to run. CPU Scheduling Algorithms(Process Selection) Multilevel Queue Scheduling It group processes into priority classes and assign a separate run queue for each class. Memory Management Memory Management Definition: Memory management is the process of controlling and coordinating computer memory, assigning portions known as blocks to various processes to optimize overall system performance. Importance: Efficient memory management is essential for multitasking, concurrent execution of processes, and resource utilization. Memory Hierarchy Memory Hierarchy Memory is organized in a hierarchy, ranging from high-speed, small- capacity registers and caches to larger, slower main memory (RAM), and even slower, larger storage devices (hard drives, SSDs). 1 Registers: Description: Registers are the fastest and smallest type of memory, located directly within the CPU. They store data that is currently being processed by the CPU. Characteristics: Extremely fast access times but limited in capacity. Memory Hierarchy 2- Cache Memory: Description: Cache memory is a small-sized type of volatile computer memory that provides high-speed data access to a processor and stores frequently used computer programs, applications, and data. Levels: Modern processors typically have multiple levels of cache (L1, L2, and sometimes L3). Characteristics: Faster than main memory, but more expensive. Helps bridge the speed gap between the fast CPU registers and slower main memory. Memory Hierarchy 3 - Main Memory (RAM - Random Access Memory): Description: RAM is used for storing data and machine code currently being used and processed by the CPU. It is volatile, meaning its contents are lost when the power is turned off. Characteristics: Larger in capacity than cache memory but slower in access speed. It's the bridge between the fast cache and slower storage devices. Memory Hierarchy 4 -Secondary Storage (Hard Drives, SSDs): Description: Secondary storage devices provide non-volatile, high- capacity storage for data and applications. Unlike RAM, data persists even when the power is turned off. Characteristics: Much slower access times compared to RAM but significantly larger in capacity. Used for long-term storage of programs and data. Memory Hierarchy Memory Access Time The time it takes to access data from a specific level of the memory hierarchy. Hierarchy Principle: Access times increase as you move down the memory hierarchy. Registers have the fastest access times, followed by cache, main memory, and secondary storage. Memory Hierarchy Cache Coherency: Ensuring that copies of data in different levels of the cache hierarchy are consistent and up-to-date. Cache Lines: Data is often transferred between levels of the cache hierarchy in fixed-size blocks called cache lines. Address Spaces Process Address Space: Each process in the system has its own address space, which is the range of valid addresses a process can use. These range is assigned/Allocated and managed by the operating system Kernel Address Space: The portion of memory reserved for the operating system kernel. Memory Allocation Strategies Fixed Partitioning: Memory is divided into fixed-size partitions, and each process is assigned a partition. Efficient use of space but can lead to fragmentation. Dynamic Partitioning: Memory is divided into variable-sized partitions to accommodate processes of different sizes. Requires dynamic allocation algorithms. Fragmentation Internal Fragmentation: Wasted memory within a partition due to allocating a larger block than necessary. External Fragmentation: Free memory is scattered in small, non- contiguous blocks, making it challenging to allocate large contiguous blocks. Memory Allocation Algorithms Memory allocation algorithms are techniques used by operating systems to assign and manage memory space for programs and processes. These algorithms aim to efficiently use the available memory while minimizing fragmentation and ensuring proper allocation and deallocation of memory resources There are several strategies for allocating free memory to processes upon request. First Fit, Best Fit, Worst Fit Memory Allocation Algorithms 1 First Fit Description: The first-fit algorithm allocates the first available memory block that is large enough to accommodate the requested size. Advantages: Simple and easy to implement. Disadvantages: Can lead to fragmentation, both internal (unused space within a block) and external (small free blocks scattered throughout). Memory Allocation Algorithms 2- Best Fit: Description: The best-fit algorithm allocates the smallest available block that is large enough to accommodate the requested size. Advantages: Reduces internal fragmentation by selecting the closest fit. Disadvantages: May lead to more external fragmentation as small leftover spaces can accumulate. Memory Allocation Algorithms 3- Worst Fit: Description: The worst-fit algorithm allocates the largest available block, leaving behind the largest leftover fragment. Advantages: Tends to create large free spaces for future allocations. Disadvantages: Can result in significant internal fragmentation. Memory Allocation Algorithms The choice of a memory allocation algorithm depends on various factors, including the nature of the applications running on the system, the types of memory requests, and the overall performance goals of the system. Different algorithms have different trade-offs in terms of speed, efficiency, and complexity. Thanks