ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

Similar documents
Processes. Process Concept

Chapter 3: Processes

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Unix Processes. What is a Process?

COMP SCI 3SH3: Operating System Concepts (Term 2 Winter 2006) Test 2 February 27, 2006; Time: 50 Minutes ;. Questions Instructor: Dr.

Processes. CS3026 Operating Systems Lecture 05

Mon Sep 17, 2007 Lecture 3: Process Management

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

Process Description and Control

Processes. CSE 2431: Introduction to Operating Systems Reading: Chap. 3, [OSC]

Operating System Structure

High Performance Computing Lecture 11. Matthew Jacob Indian Institute of Science

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

CS 333 Introduction to Operating Systems Class 2 OS-Related Hardware & Software The Process Concept

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Processes. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & Apps 1

Processes and Threads

Fall 2015 COMP Operating Systems. Lab #3

PROCESSES. Jo, Heeseung

Processes. Jo, Heeseung

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Course: Operating Systems Instructor: M Umair. M Umair

CS399 New Beginnings. Jonathan Walpole

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

CPS 310 first midterm exam, 2/26/2014

CS 333 Introduction to Operating Systems. Class 2 OS-Related Hardware & Software The Process Concept

Processes. Sanzheng Qiao. December, Department of Computing and Software

Process Concepts 8/21/2014. CS341: Operating System. Scheduling: Theoretical Analysis

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Lecture 2 Process Management

CS Lecture 2! Processes! George Mason University! Fall 2010!

CS 3733 Operating Systems

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

Chapter 3: Processes. Chapter 3: Processes. Process in Memory. Process Concept. Process State. Diagram of Process State

Memory Management - Demand Paging and Multi-level Page Tables

Multiprogramming. Evolution of OS. Today. Comp 104: Operating Systems Concepts 28/01/2013. Processes Management Scheduling & Resource Allocation

Operating Systems CS 571

Processes in linux. What s s a process? process? A dynamically executing instance of a program. David Morgan. David Morgan

csci3411: Operating Systems

Part Two - Process Management. Chapter 3: Processes

Chapter 3: Process Concept

Chapter 3: Process Concept

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

Process. Program Vs. process. During execution, the process may be in one of the following states

Chapter 3: Processes. Operating System Concepts 8th Edition,

System Programming. Introduction to Unix

Chapter 4: Processes. Process Concept

Processes and Threads

What is a Process. Processes. Programs and Processes. System Classification 3/5/2013. Process: An execution stream and its associated state

Most of the work is done in the context of the process rather than handled separately by the kernel

CSE 153 Design of Operating Systems Fall 2018

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

Processes. Operating System Concepts with Java. 4.1 Sana a University, Dr aimen

Chapter 4: Processes

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Announcements Processes: Part II. Operating Systems. Autumn CS4023

Linux Operating System

(MCQZ-CS604 Operating Systems)

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

www nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed

ENGR 3950U / CSCI 3020U UOIT, Fall 2012 Quiz on Process Synchronization SOLUTIONS

Use of interaction networks in teaching Minix

CSC 2405: Computer Systems II

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-1: PROCESS

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination.

Processes. Dr. Yingwu Zhu

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Processes. CS 416: Operating Systems Design, Spring 2011 Department of Computer Science Rutgers University

The Big Picture So Far. Today: Process Management

Chapter 3: Process Concept

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

Announcement. Exercise #2 will be out today. Due date is next Monday

CSCE 313: Intro to Computer Systems

Inter-Process Communication

Process Management! Goals of this Lecture!

PESIT Bangalore South Campus

Problem Set: Processes

Diagram of Process State Process Control Block (PCB)

Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Introduction to Process in Computing Systems SEEM

Physical memory vs. Logical memory Process address space Addresses assignment to processes Operating system tasks Hardware support CONCEPTS 3.

Operating System Design

ENGR 3950U / CSCI 3020U (Operating Systems) Simulated UNIX File System Project Instructor: Dr. Kamran Sartipi

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Universidad Carlos III de Madrid Computer Science and Engineering Department Operating Systems Course

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

Lecture 5: Process Description and Control Multithreading Basics in Interprocess communication Introduction to multiprocessors

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

Processes, PCB, Context Switch

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Transcription:

SOLUTIONS ENGR 3950U / CSCI 3020U (Operating Systems) Midterm Exam October 23, 2012, Duration: 80 Minutes (10 pages, 12 questions, 100 Marks) Instructor: Dr. Kamran Sartipi Question 1 (Computer Systgem) [8 marks] In the computer system below: a. What are the main Bus s that connect the CPU to different components of the computer system (i.e., memory, and controllers). Briefly explain how each Bus is used. Address Bus (uni-directioanl): CPU drives the address bus to address memory locations and to activate different I/O devices. The size of address bus determines the number of memory locations that the CPU can access. Low part of the address lines are directly connected to memory or I/O devices, but the high-part of it is used by address decoders to enable memory or I/O devices. Data Bus (bi-directioanl): Data bus connects CPU to the rest of components in the computer system (i.e., memory, DMA, and I/O controllers) to transport parallel data between CPU and other components. At each instance only two components can be connected to the data bus, and the others must be disconnected (high-impedence or tri-state). Control Bus (uni-directional): Control lines include: memory read/write; I/O read/write; hold; wait; interrupt; interrupt acknowledge; reset; etc. These lines are used to enable/disable different devices (and CPU) for different purposes. Page 1 of 9

b. How many address lines are needed (for the address Bus) to address a memory with size 128 Giga Bytes? Show your calculation below. 1KB 2^10 10 lines 1MB 2^20 20 lines 1GB 2^30 30 lines 128 2^7 7 lines 128 GB 2^30 x 2^7 2^37 37 lines c. In the above computer system, explain the advantage of using DMA (Direct Memory Access) compared to using CPU for transferring data from disk controller to memory. DMA can be used to send data from local buffer of disk controller to main memory without CPU intervention. To use DMA after setting up buffers pointers, and counters for the I/O device, the device controller transfers an entire block of data directly from its own buffer to memory with no intervention by the CPU. Only one interrupt is generated per block rather than one interrupt per byte. While the device controller is performing these operations the CPU is available to accomplish other works. Using DMA for data transfer has high advantage over using CPU to reduce overhead when transferring large data. It also makes better use of CPU-time by letting the CPU do other tasks during data movement. Moreover, during data transfer the BUS is being used by DMA, and the CPU can t use BUS. d. Can a DMA and the CPU work in parallel? Why? Yes, during the data transfer from device controller buffer to memory (or the reverse direction) by the DMA, the CPU disconnects itself from the system BUS but it can perform internal operations such as decoding instruction opcodes and performing arithematic and logic operations using ALU. Question 2. Give 3 reasons for Process Creation and five reasons for Process Termination. [8 Marks] Page 2 of 9

Question 3. Name five items in the Process Control Block (PCB). [5 Marks] Process state Process id Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information Question 4 [7 marks] Figure below is part of a lecture slide representing the application of command process status ( ps ) in Unix OS. In simple steps and with the logic we discussed in class, explain how you would identify the shell process -tcsh of a crashed terminal and kill the process to release the terminal. UID: user ID; PID: process ID; PPID: parent PID; TTY: terminal; CMD: command. In the above example, the first line belongs to the currently created shell process since its PID is close to the PID of the "grep ksartipi" command (two PIDs 9002 and 9092), as opposed to the PID of the shell process in the second line (11670). Now, you can kill the crashed shell process by the command: "kill -9 11670" at the Unix prompt and release the crashed terminal. Page 3 of 9

Question 5. Using the line-numbers in the C code shown below: [10 Marks] 1 Int main ( ) { 2 int pid; 3 /* fork another process */ 4 pid = fork (); 5 if (pid < 0) { /*error occurred */ 6 fprintf (stderr, Fork Failed ); 7 exit (-1); 8 } 9 else if (pid == 0) { /* child process */ 10 execlp ( /bin/ls, ls, NULL); 11 } 12 else { /* parent process */ 13 /* parent will wait for the child to complete */ 14 wait (NULL); 15 printf ( Child Complete ); 16 exit (0); 17 } 18 } a) What is the value of PID in line 4: PID = fork(); after returning from the fork system call, and why? fork() retunes the PID of child process for the parent process, and returns 0 for the child process. b) Briefly explain different parts of the code in order to perform a fork() system call, including the synchronization between parent and child processes. Line 2: defines an Integer variable to store the child s PID Lines 4-8: The process performs a fork() system call to create a child process which is completely similar to the this process. This fork() retunes the PID of child process for the parent process, and returns 0 for the child process. If the fork() system call is not successful, the OS returns a negative number which causes an exit(-1) in which case the program terminates by indicating an error. Lines 9-11: The child process performs this part (since it receives 0). It then executes execlp( ) operation which causes the OS to: i) access the executable file with pathname /bin/ls from the file system; ii) place it into the address space of the child process; and iii) run the command ls (list) on it, and return NULL signal after Page 4 of 9

termination. Lines 12-17: The parent process performs this part. It performs wait (NULL) command which causes it to block itself and wait until it receives a signal from OS that its child has terminated (with signal NULL). Then the parent process prints Child Complete and exits normally exit(0). Question 6 (IPC) [6 marks] In a remote procedure call (RPC) mechanism between a client and a server computers using sockets, what happens if the client process does not know the port-number of the server process to make the connection. Answer briefly. The server runs a matchmaker daemon on a known port. The client contacts the matchmaker daemon, providing a service or procedure name that it wishes to access. Then the matchmaker daemon returns the proper port number to the client. The client contacts service on the server using this port. In most cases the OS will take care of this steps on behalf of the client. Question 7 (File System) [14 Marks] Consider figure below to answer the following questions using the terms listed below: Allocation; File descriptor; Path-name component; I-node; Index block; I-number; Access permission; File permissions; Open-file counter; Pointer to file blocks; File owner name; File size; File dates; Super block; File allocation table; File control block. a. What are the contents of each directory entry in A? <Path-name component, I-number> b. What is the name of indices shown by B? I-number c. Name three items in C. File permissions; Open-file counter; Pointer to file blocks; File owner name; File size; File dates; d. What is the specific name of the indices shown by D? File descriptor Page 5 of 9

e. What are the contents of each entry E? Access permission; f. Which of the entries A, C, or E contains a pointer to file blocks? C g. Show how 4 blocks from the hard disk can be used as data blocks for a file X using Unix index allocation method.. Page 6 of 9

Question 8. What is the Principle of Locality? How is this concept used in designing cache memory? [6 Marks] Program and data references within a process tend to cluster. Therefore, in a short period of time the process will access to memory locations that are close to each other (adjacent). After a short period of time the CPU addresses to another location and performs the code or accesses data that are closely located in memory in that location. For this reason it is reasonable that when the process addresses a location in memory the hardware (Memory Management Unit MMU) automatically move a block of memory from that location to the cache memory which is much faster than main memory. Therefore, due to the Principle of Locality of Reference, with very high chance (above 90%) the next memory access can be done from the cache (not from main memory). This is the reason that computer systems have cache memory. Question 9. For each statement below, indicate whether it is False or True. In case of False briefly explain why. [10 Marks] a) Multiprogramming is intended to increase CPU utilization, and time-sharing is intended to increase computer s responsiveness in interacting with user. True. b) A heavy-weight process is a thread which can handle a large task. is a Unix process which.. c) A parent-process and its child-processes can easily communicate information since they share the same address space. True. d) Threads have difficulty in communicating information among each other since they do not share the address space of their process. Threads have ease in communication since they do share e) CPU has two modes of operations as user mode and kernel mode, where the kernel mode is used for accessing privileged library functions. privileged I/O functions. Page 7 of 9

Question 10. Why in a busy system with several processes in memory, the ready queue becomes empty and the CPU becomes idle? How does the operating system handle this situation to increase CPU utilization? [6 Marks] Suppose all processes need to use I/O devices for their tasks; for example, printing, waiting for keyboard; waiting for disk blocks, waiting for memory to be allocated, etc. Since the speed of I/O operations are much slower than CPU operation (some orders of magnitude) then all processes after a short period of time block themselves and wait for their requested resources to be available. In this case the Ready Queue becomes empty and CPU becomes idle. In this situation, the OS admits more processes (i.e., brings more programs from disk to memory to be executed) in order to make Ready Queue full and active. Question 11. (Threads) For each statement below, indicate whether it is False or True. In case of False briefly explain why. [8 Marks] a) User-level threads are created and managed by thread libraries and they are easy to create and delete. True b) If a user-level thread is blocked for I/O operation, the kernel of operating system will perform context switching to run another user-thread which is not blocked. The Kernel does not have any information about the user-level threads, therefore, it can not do task switching for user-level threads. c) For efficiency, the operating system maintains a pool of threads to allocate to different tasks? True d) Many-to-One is the most efficient model of multi-threading since it allows several user-level threads to be assigned to different processors in a multi-processor computer system. Many-to-One uses one kernel thread therefore it cannot use multi-processor facility. Question 12 (False / True) [12 Marks] Answer False or True. In case of False briefly explain why. a) Lower level of file system implementation deals with logical file names and logical properties of files. Page 8 of 9

High level of file system implementation. b) Various files can be allocated space on disk through "contiguous", "linked", or "hyper-linked" allocation mechanisms. Indexing c) "File descriptor" is the name of a pointer which points to an entry in the perprocess open-file table. True. d) Super block in hard disk consists of all references to the open file blocks. System-wide open-file table in memory e) In Linked Allocation mechanism, all the pointers to a file s data blocks are collected in one block called linked block. In Index Allocation f) Unix uses both direct blocks, and index blocks for disk allocation to files, where direct block addressing is used for fast accessing to small files. True. END Page 9 of 9