This document contains homework questions about processes and operating systems concepts. It asks the student to define key terms like processes, daemons, process states, multithreading, and real-time systems. It also asks the student to explain concepts such as process termination, critical sections, scheduling algorithms, and differences between terms like turnaround time and response time. The student is asked to answer 12 questions in total.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
207 views
CS351 Chapter 2 Homework Questions
This document contains homework questions about processes and operating systems concepts. It asks the student to define key terms like processes, daemons, process states, multithreading, and real-time systems. It also asks the student to explain concepts such as process termination, critical sections, scheduling algorithms, and differences between terms like turnaround time and response time. The student is asked to answer 12 questions in total.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Chapter 2 Homework Questions
Answer the following questions. (2 points each - 24 points)
1. What is a process and what are the four principal ways they are created? A process is an executing program. There are four principal events that cause processes to be created: 1. System initialization. 2. Execution of a process creation system call by a running process. 3. A user request to create a new process. 4. Initiation of a batch job.
2. What is a daemon? Processes that stay in the background to handle some activity such as e-mail, Web pages, news, printing, and so on are called daemons.
3. How can processes be terminated? Sooner or later the new process will terminate, usually due to one of the following conditions: 1. Normal exit (voluntary). 2. Error exit (voluntary). 3. Fatal error (involuntary). 4. Killed by another process (involuntary). Most processes terminate because they have done their work. When a compiler has compiled the program given to it, the compiler executes a system call to tell the operating system that it is finished. This call is exit in UNIX and ExitProcess in Windows.
4. Explain the three process states? 1. Running (actually using the CPU at that instant). 2. Ready (runnable; temporarily stopped to let another process run). 3. Blocked (unable to run until some external event happens).
5. What is a process table and what type of information does it contain? To implement the process model, the operating system maintains a table (an array of structures), called the process table, with one entry per process. (Some authors call these entries process control blocks.) This entry contains important information about the process' state, including its program counter, stack pointer, memory allocation, the status of its open files, its accounting and scheduling information, and everything else about the process that must be saved when the process is switched from running to ready or blocked state so that it can be restarted later as if it had never been stopped.
6. Explain the concept of multithreading and give an example. What threads add to the process model is to allow multiple executions to take place in the same process environment, to a large degree independent of one another. Having multiple threads running in parallel in one process is analogous to having multiple processes running in parallel in one computer. The term multithreading is also used to describe the situation of allowing multiple threads in the same process. For example, when a thread performs a system call to read from the keyboard, it is blocked until input is typed.
7. Explain mutual exclusion and critical region, and how they are related. Mutual exclusion is a way to prohibit more than one process from reading and writing the shared data at the same time. Sometimes a process has to access shared memory or files, or do other critical things that can lead to races. That part of the program where the shared memory is accessed is called the critical region or critical section. If we could arrange matters such that no two processes were ever in their critical regions at the same time, we could avoid races. Although this requirement avoids race conditions, it is not sufficient for having parallel processes cooperate correctly and efficiently using shared data. We need four conditions to hold to have a good solution: 1. No two processes may be simultaneously inside their critical regions. 2. No assumptions may be made about speeds or the number of CPUs. 3. No process running outside its critical region may block other processes. 4. No process should have to wait forever to enter its critical region.
8. Compare and contrast semaphores, monitors, and message passing. A semaphore can be used to ensure that one section of code is run before another section, even when theyre in different processes. Monitors encapsulate data structures that are not externally accessible. A monitor can have condition variables that can be used to add additional synchronization behavior beyond basic mutual exclusion. Message passing involves context switching and copying the messages. The wait and signal operations on condition variables in a monitor are similar to P and V operations on counting semaphores. A wait statement can block a process's execution, while a signal statement can cause another process to be unblocked. However, there are some differences between them. When a process executes a P operation, it does not necessarily block that process because the counting semaphore may be greater than zero. In contrast, when a wait statement is executed, it always blocks the process. When a task executes a V operation on a semaphore, it either unblocks a task waiting on that semaphore or increments the semaphore counter if there is no task to unlock.
9. Compare and contrast the scheduling algorithms used in batch systems. First Come First Served -This scheduling method is used on Batch-Systems, it is NON-PREEMPTIVE. It implements just one queue which holds the tasks in order they come in. The order the tasks arrive is very important for the Turnaround-Time: Task1(24) Task2(6) Task3(6) avg. Turnaround-Time = (24 + 30 + 36) / 3 = 30 time units (this assumes all tasks arrive at time 0) Task1(6) Task2(6) Task3(24) avg. Turnaround-Time = (6 +12 +36) / 3 = 18 time units (this assumes all tasks arrive at time 0) Strengths: -Simple -Fair Problems: -Convoy Effect -Order of task arrival is very important for average Turnaround time
10. What is a real-time system, and what are the two types? Real-time systems have different properties than interactive systems, and thus different scheduling goals. They are characterized by having deadlines that must or at least should be met. For example, if a computer is controlling a device that produces data at a regular rate, failure to run the data- collection process on time may result in lost data. Real-time systems are generally categorized as hard real time, meaning there are absolute deadlines that must be met, or else, and soft real time, meaning that missing an occasional deadline is undesirable, but nevertheless tolerable.
11. What is the difference between turnaround time and response time? Turnaround time - total time between submission of a process and its completion. Response time - amount of time it takes from when a request was submitted until the first response is produced.
12. What is a race condition? A race condition occurs when two or more threads can access shared data and they try to change it at the same time.
Chapter 2 problems. Answer problems 1, 3, and 37 at the end of chapter 2 on pages 170- 173. (problem 1 is 2 points and #s 3 and 37 are 3 points each - 8 total).