اململكة العربية السعودية Kingdom of Saudi Arabia Ministry of Higher Education Prince Sattam Bin Abdul-Aziz University College of Computer Engineering and sciences وزارة التعليم العايل جامـعـة األمري سطام بن عبدالعزيز كل ـي ــة هـنــدس ــة وعلـ ــوم احلـاســب 2440 & 2544 :الشعبة Course Title: CS3701-Operating System CSC3701 Instructor Name: Mr. Abdul Haseeb Khan Tutorial Lecture # 01 CH: Introduction to Operating Week# 01 System Date: 31-08-2015 Objective: Introduction basic concepts of operating system Q. 1 what is an operating system? Answer: It is a program that acts as an intermediary between the user and the computer hardware. It makes it easy for the user to use the computer hardware. It enables efficient use of the computer hardware by acting as a resource allocator. Q. 2 draw a diagram showing relative position of the components of a computer system: the hardware, the operating system, the system and application programs and the users. Answer: See the book or slides. Q. 3 how do a computer system boot or start-up? Answer: All computer systems have a bootstrap program, which gets executed automatically at power up. The bootstrap program is permanently stored in a ROM. Bootstrap program loads the OS kernel into the main memory and starts its execution. Once started OS waits for an event to happen, such as user typing in a command. Q. 4 draw a diagram showing internal components: CPU, memory, USB controller, etc. organized around a common bus. Answer: See the book or slides. Q.5 What is an interrupt? What is a trap? Answer: Interrupt is a hardware signal or an instruction that causes CPU to stop what it is doing and execute a routine to handle the interrupt. The routine is called interrupt service routine. On completion the CPU resumes the interrupted computation. A trap is a software generated interrupt caused either by an error or a user request. Q. 6 how are interrupts handled by the CPU? Answer: 1. CPU stops what it is doing and transfers execution to a fixed location (in an interrupt vector. See the question below). The fixed location contains the starting address of the interrupt service routine. The values of various registers in the CPU and program counter are saved. 2. The interrupt service routine is executed. 3. Values of various registers and program counter, previously stored, are restored. CPU resumes the interrupted computation. Q. 7 what is an interrupt vector? Answer: It is an array of memory locations that stores the addresses of the interrupt service routines. Q. 8 what is a synchronous and asynchronous I/O? Answer: Synchronous I/O – after I/O starts, CPU waits for the I/O to finish and control returns to the user program only after I/O completion. Asynchronous I/O -- after I/O starts, control returns to the user program without waiting for I/O completion. Example: I/O through DMA. Q. Draw the diagram showing the timelines for each type. See the book or the slides. Q. 9 what is device status table? Device status table contains entry for each I/O device indicating its type, address and state. Used during I/O. Q. 10 what is Direct Memory Access (DMA) transfer? It is a type of I/O in which a block of data is transferred from the buffer storage directly to the main memory without CPU intervention. DMA is much faster than I/O in which CPU transfers small amounts of data. Q. 11 what are device controllers and device drivers? How are they used during I/O? Answer: (a) Each device in a computer system (e.g. keyboard, disk drive, etc.) has a device controller, usually in the form of an IC chip, connected to the bus. The device controller has buffer storage and some registers. Device controller is responsible for moving data between the devices it controls to its buffer storage. OS have device drivers for each device controller. Device driver understands the device controller and presents a uniform interface to the device to the rest of the operating system. (b) To start an I/O operation, the device driver loads the appropriate registers in the device controller. The device controller, in turn, decodes the contents of these registers to determine the action to take (such as “read a character from the keyboard”). The controller transfers data from the device to its local buffer. Once the transfer is complete the controller informs the device driver via an interrupt that it has finished the operation. Device driver then returns control to the operating system with data and status information. Q. 12 List various type of storage used in a computer system and give capacity and speed (access time) of each type. Draw the storage hierarchy. Answer: See the slides or the book. Q. 13 what is caching? Answer: Cache is type of memory that has very low access time (it is high speed). To improve the speed of computation (or performance) data that is frequently needed during computation is copied from the high-access time (or low speed) main or secondary memory and kept in the cache, where it can be accessed quickly. This process is called caching. Q. 14 what are single-processor systems and multi-processor systems? In a single-processor system, there is one main CPU capable of executing a general purpose instruction set. Multi-processor systems have more than one CPU connected to the same bus and sharing other resources such as memory, devices etc. Multi-processor systems are also known as parallel systems or tightly-coupled systems. Q. 15 what is the difference between symmetric and asymmetric multiprocessing? Answer: In asymmetric multiprocessing each processor is assigned a specific task. A master processor controls the system; other processors take instructions from the master processor or have predefined tasks. In symmetric multiprocessing each processor performs all tasks within the operating system. Q. 16 what is an interactive system? Answer: A computer system in which user gives instructions/commands to the system directly through a keyboard or a mouse and waits for the system to respond back through an output device such as a monitor. The response time of an interactive system is less than one second. Q. 17 what are multi-programmed and non-multi-programmed systems? Answer: In a multi-programmed system OS keeps many jobs in the memory. It picks up and starts execution of one of the jobs. When the job has to wait for some task, such as I/O operation to complete, OS switches to and starts execution of another job. Similarly when that job has to wait, OS switches to another job and so on. CPU never remains idle. In a non-multi-programmed system the OS does not switch to another job but waits for the I/O to complete. CPU remains idle during this time. Q. 18 what is the advantage of multi-programming? Answer: Multi-programming enables efficient utilization of system resources such as CPU, memory and peripheral devices. Q. 19 briefly describe timesharing or multitasking? Answer: Time shared or multi tasked system is a multi-programmed system in which CPU executes multiple jobs by switching among them, but the switches occur after a job is executed for a short period of time or the job has to wait for an I/O. The CPU time allocated to a job is called its time slice and can be very short, for example, a few milliseconds. Since the job switches happen quickly multiple users are able to work with the system interactively at the same time. Q. 20 what is a process? Answer: A program loaded into the memory and under execution is called a process. Q. 21 Name the two modes in which a computer system can operate. Answer: (i) Kernel mode (also known as system mode, supervisor mode or privileged mode). In this mode the CPU runs/executes operating system code. (ii) User mode. In this mode the CPU runs/executes a user program. Q. 22 Why is it necessary to have two modes of operation for a computer system? Answer: User programs can be incorrectly written, malicious or may generate errors. They can interfere with the functioning of the OS. For example, a user program can overwrite operating system code with data. For this reason two modes of operation are provided: user mode and kernel mode. Some instructions can only be executed in kernel mode and not in user mode; certain areas of memory can also be accessed only in kernel mode. The two modes are distinguished by a mode bit in the hardware. Mode bit is 1 in user mode and 0 in kernel mode. Q. 23 Name various computing environments. Answer: a. Batch b. Interactive c. Time sharing d. Real time e. Network f. Parallel g. Distributed Q. 24 what do the following terms mean? Kernel, BIOS, firmware, bus, routine, system call, process, job, job pool Answer: Kernel: In computing, the kernel is the main component of most computer operating systems; it is a bridge between applications and the actual data processing done at the hardware level. The kernel's responsibilities include managing the system's resources (the communication between hardware and software components). Usually, as a basic component of an operating system, a kernel can provide the lowest-level abstraction layer for the resources (especially processors and I/O devices) that application software must control to perform its function. It typically makes these facilities available to application processes through inter-process communication mechanisms and system calls. 2nd Definition: In computing, the kernel is a computer program that manages I/O (input/output) requests from software, and translates them into data processing instructions for the central processing unit and other electronic components of a computer. The kernel is a fundamental part of a modern computer's operating system. When a computer program (in this context called a process) makes requests of the kernel, the request is called a system call. Various kernel designs differ in how they manage system calls and resources. For example, a monolithic kernel executes all the operating system instructions in the same address space in order to improve the performance [clarification needed] of the system. A microkernel runs most of the operating system's background processes in user space to make the operating system more modular and, therefore, easier to maintain. (For others see Book.)