Operating System Written Assignments 1-3
What is the Windows function call that causes a parent threat to waits for a child thread to finish?
WaitForSingleObject()
Multicore also means multiple CPUs. True or False
False
A UNIX/Linux _______ process is assigned as the parent to orphan processes
systemd
A microkernel is a kernel ____
that is stripped of all nonessential components
A ____ provides an API for creating and managing threads
thread library
A _____ uses an existing thread — rather than creating a new one — to complete a task
thread pool
What are the three main purposes of an operating system?
to execute user programs and make solving user problems easier, make the computer system convenient to use, and use the computer hardware in an efficient manner.
Explain the difference between preemptive and nonpreemptive scheduling.
Nonpreemptive only happens when a process terminates or when a process switches from a running state to a waiting state. Moreover, when the CPU is allocated to a process, the process holds the CPU until it is terminated or it is switched to a waiting state. Preemptive scheduling happens when a process switches from the running state to the ready state. In addition, preemptive scheduling happens when a process changes from the waiting state to the ready stat
__________ provide an interface to the services made available by an operating system
System Calls
What is the purpose of system calls?
System calls allow for users to have an interface to the services from the operating system. System calls allow the user to call the system for a task that they don't have access to complete themselves
What is the purpose of system programs?
System programs are what allow users to interact with system calls. They are between the user mode and kernel mode
Explain the circumstances under which the line of code marked printf("LINE J") in the figure below will be reached #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ ,,,,,,,,,execlp("/bin/ls","ls",NULL); printf("LINE J"); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); } return 0; }
If the exec call is not succesful
A stack uses the ______ principle for organizing data while a queue uses the ________ principle
LIFO, FIFO
___ is a software framework that provides additional services (to those provided by an operating system) to application developers.
Middleware
Waiting -> Ready
The event for which the process was waiting has occured
What is the main advantage of the layered approach to system design? What are the disadvantages of the layered approach
The main advantages of the layered approach is system verification, simplicity of construction, and debugging. The disadvantages of the layered approach are the difficultyof appropriately defining the functionality of each layer. In addition, the layered approach results in the systems usually having poor performance due to the need for the user to traverse through multiple layers
What are two differences between user-level threads and kernel-level threads? Under what circumstances is one type better than the other?
The main difference between user level threads and kernel level threads is that user level threads are implemented by the user of the machine and kernel threads are implemented by the OS. Another difference between the two is the time it takes to perform a context switch. User level threads perform context switching faster than kernel level threads.
What is the valid test for determining if the bounded buffer is empty?
(in == out)
What is the type of parameter that is passed to the Java Thread() constructor?
The name of a class the implements the runnable interface
What does the third parameter passed to the pthread_create() function specify?
The name of the function that will be run by the thread being created
How does the distinction between kernel mode and user mode function as a rudimentary form of protection (security
User mode has restricted access so that something in user mode can't write or change anything in the Kernel or process. On the other hand, Kernel mode is when the operating system has control of the machine. When a system call is made in user mode the bit changes to 1 as it enters Kernel mode. The operating system takes control and completes the task and returns back to user mode. These are "privileged instructions" that the user doesn't have access to. This is to ensure that the users can't harm the operating system
What system calls have to be executed by a command interpreter or shell in order to start a new process on a UNIX system?
Using a Unix system a fork system call and an exec call made by the command interpreter or shell must be made to start a new process
_______ is a technology that abstracts the hardware of an actual computer into several different execution environments
Virtualization
Describe the actions taken by a kernel to context-switch between kernel-level threads
When a context-switch occurs between kernel-level threads the value of the registers are saved from the switch and then are reloaded into the registers in the new thread
What resources are used when a thread is created? How do they differ from those used when a process is created?
When a thread is created, the resources used include the stack, the next instruction, and the memory of the process it belongs to. The difference between creating a process and a thread is that the information for thread tracking is much smaller than the information in the process because it must create a new address.
________ is a technique for resolving data representation differences between two hosts communicating using RPCs
XDR (external data representation)
What best explains why shared memory is typically faster than message passing? a.) Message passing is implemented in system calls which requires kernel intervention; shared memory only requires a system call to establish the shared memory segment. b.) Message passing is typically used for sharing large amounts of data. c.) Message passing is only used in distributed systems where communication takes place across a slower network.
a.)
Which of the following is a property of peer-to-peer systems? a.) Clients and servers are not distinguished from one another. b.) Peer-to-peer systems do not offer any advantages over traditional client-server systems. c.) Peer-to-peer systems suffer from the server acting as the bottleneck in performance.
a.)
Which of the following is not an example of a wait queue? a.) Ready queue b.) Child termination queue c.) I/O queue
a.)
Which of the following is not considered a form of a system utility? a.) Application programs b.) Programming language support c.) Background services
a.)
Using Amdahl's Law, calculate the speedup gain of an application that has a 60 percent parallel component for (a) two processing cores and (b) four processing cores
a.) 1.42 b.) 1.82
Process Arrival Burst time p1 0.0 8 p2 0.4 4 p3 1.0 1 (a) What is the average turnaround time for these processes with the FCFS scheduling algorithm? (b) What is the average turnaround time for these processes with the SJF scheduling algorithm? (c) The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be known as future-knowledge scheduling
a.) 10.53 b.) 9.53 c.) 6.86
Which of the following instructions should be privileged: a.) Set value of timer. b.) Read the clock. c.) Clear memory. d.) Issue a trap instruction. e.) Turn off interrupts. f.) Modify entries in device-status table. g.) Switch from user to kernel mode. h.) Access I/O device
a.) set value of timer c.) Clear memory e.) Turn off interrupts g.) Switch from user to kernel mode f.) Modify entries in a device-status table h.) Access I/O device
Message passing in Windows is known as _______ .
advanced local procedure call
A socket address consists of ___________ and ___________ .
an IP address, a port number
A device controller informs a device driver it has completed an I/O operation using ________
an interrupt
The major difficulty in designing a layered operating system approach is ___
appropriately defining the various layers
Terminating a running application using a keystroke sequence causes a(n) __________ exception.
asynchronous
A process may transition to the Ready state by which of the following actions? a.) While the process is waiting for completion of an I/O event b.) The process timed out or it has requested an operation (a waited I/O or a semaphore WAIT). c.) The process is dispatched by the scheduler to run on a CPU core.
b.)
Which of the following is not true of clustered systems? a.) They can provide high-availability service. b.)Because they are typically connected across a computer network, they cannot meet high-performance computing needs. c.) Data sharing is still possible on clustered systems even though the cluster consists of separate computer systems.
b.)
A client with IP address 150.55.66.77 wishes to download a file from an HTTP server at IP address 202.28.15.123. Select the valid socket pair for a connection between this pair of hosts. a.) 150.55.66.77:80 and 202.28.15.123:80 b.) 150.55.66.77:150 and 202.28.15.123:80 c.) 150.55.66.77:2000 and 202.28.15.123:80
c.)
Which of the following is not a technique that allows a program to be run by different operating systems? a.) The program is written in an interpreted language such as Python. b.) The program is written in a language that includes a virtual machine as part of the application's runtime such as Java. c.) The program has been compiled into a binary executable file.
c.)
A process control block ____
contains a process' states
_________________ saves the state of the currently running process and restores the state of the next process to run.
context switch
When OpenMP encounters the #pragma omp parallel directive, it
creates as many threads as there are processing cores
Thread-local storage is ____.
data that is unique to each thread
Cancellation points are associated with ____ cancellation.
deferred
Policy ____.
determines what will be done
A _____ provides a file-system interface which allows clients to create and modify files
file-server system
In Pthreads and Windows threads any data declared _____ are shared by all threads belonging to the same process
globally
Which of the following forms of storage has the largest capacity? registers hard-disk drives nonvolatile memory
hard disk drives
Each Windows thread _____
has a user stack and a kernel stack
A monolithic kernel _____________ .
has very limited or no structure at all
A ________ associates [key:value] pairs
hash map
The _______ multithreading model multiplexes many user-level threads to a smaller or equal number of kernel threads
many-to-many
A(n) ______________ allows several unrelated processes to use the pipe for communication
named pipe
The _______ multithreading model is used by both Linux and Windows
one-to-one
_______ system allows more than one task to run simultaneously.
parallel
Bluetooth devices use wireless technology to communicate over several feet, in essence creating a ____
personal-area network
Grand Central Dispatch handles blocks by
placing them on dispatch queue
A/an ___ is an instance of a program in execution.
process
The ________ is the physical chip that contains one or more CPUs.
processor
Embedded computers typically run on a ____ operating system
real-time
What type of process is created by the Chrome browser for each tab that is opened?
renderer
A blocking send() and blocking receive() is known as a(n) ________________.
rendezvous
UNIX systems escalate privileges by setting the _______ attribute.
setuid
A ______ is another term for command interpreter
shell
Two important design issues for cache memory are ___
size and replacement policy
The convention in modern operating systems and compilers is that the ____ of a process contains temporary data such as function parameters, return addresses, and local variables.
stack
Which of the following is not shared by threads?
stack
______ refers to the special operation which allows a user program to request an operating system service
system call
Which of the following terms is not considered another term for kernel mode? user mode system mode privileged mode
user mode
What best describes the return value from fork() for the child process?
value of 0
A UNIX/Linux process that calls exit() to terminate, but whose parent has not yet called wait(), is known as a ________ process
zombie
____ is/are not a technique for passing parameters from an application to a system call
Cache Memory
Give two reasons why caches are useful. What problems do they solve? What problems do they cause? If a cache can be made as large as the device for which it is caching (for instance, a cache as large as a disk), why not make it that large and eliminate the device?
Caches are able to improve transfer times between two different components of differing speeds. In addition, caches are faster at retrieving data than both main and secondary memories. Overall, caches significantly speed up operating systems that are attempting to access data and transfer data. Although, caches can be inaccurate and cause problems with data. When data is changed the cache must also change. This becomes a problem when another processing system is using the data and the cache updates that data. A large cache device would cause the CPU to overheat and also would be expensive
Does the multithreaded web server described in Section 4.1 exhibit task or data parallelism?
Data parallelism
______ is the preferred form of cancellation
Deferred cancellation
Some computer systems provide multiple register sets. Describe what happens when a context switch occurs if the new context is already loaded into one of the register sets. What happens if the new context is in memory rather than in a register set and all the register sets are in use
During a context switch, the kernel saves the context, within the kernel's PCB, of the old process and then begins to load in the saved context to the new process that is going to run. If the new context is in the memory, one of the contexts already in a register set must be moved into the memory to make room for the new context, which is then loaded into the now free register set.
Deferred cancellation is guaranteed to ultimately terminate the target thread true or false
False
Examples of the _______ model include applications such as word processors or spreadsheets that run in the cloud and may be accessed via the internet.
Software as a service
_________ involves distributing tasks across multiple computing cores
Task parallelism
What best describes what occurs when a child process calls the exec() system call?
The child process has a new program loaded into it.
What is the purpose of the command interpreter? Why is it usually separate from the kernel?
The command interpreter is given control from the operating system when an abnormal instruction or error occurs. The command interpreter continues the next command from the user. The command interpreter can also determine the next action based on the error.It is separate from the kernel because the interpreter is liable to change.
_______ combines relocatable object files into a single executable file
A linker
According to Amdahl's Law, what is the maximum speedup gain on a system with 4 processing cores for an application that is 20% serial?
2.50
What is the relationship between threads and processes?
A process consists of one or more threads
Running -> Ready
A timeout has occurred
What best describes a maskable interrupt?
An interrupt that can temporarily be disabled
Message passing with direct communication requires ______
Both the send() message and receive() message functions to specify a process as a parameter to the function
Keeping in mind the various definitions of operating system, consider whether the operating system should include applications such as web browsers and mail programs. Argue both that it should and that it should not, and support your answers
On one hand, operating systems should include applications in order to provide instant access to the web for its users. Adding something such as web browsers into the operating system would simplify the process of setting up the operating system for users. On the other hand, adding applications to the operating system would minimize the control users would have with their device. For example, if a web browser were included in the system, users would not be able to uninstall it. Moreover, they would not be able to choose what the included applications ar
Give an example of a situation in which ordinary pipes are more suitable than named pipes and an example of a situation in which named pipes are more suitable than ordinary pipes
Ordinary pipes are more suitable than named pipes in a situation when using parent processes and child processes that are created using fork(), in a unidirectional manner. Named pipes are more suitable when the programmer wants to have bidirectional communication between multiple processes. Moreover, if the programmer doesn't need to use parent and child processes, named pipes don't require it
What output will be at Line A? #include <sys/types.h> #include <stdio.h> #include <unistd.h> int value = 5; int main() { pid_t pid; pid = fork(); if (pid == 0) { /* child process */ value += 15; return 0; } else if (pid > 0) { /* parent process */ wait(NULL); printf("PARENT: value = %d",value); /* LINE A */ return 0; } }
PARENT: value = 5
Running -> Terminated
Process exits
Ready -> Running
Process is selected to run on a processing core
Running -> Waiting
Process needs to wait for an event (such as completion of an I/O operation)
Which of the following operating system services is related to ensuring the efficient operation of the system and is unrelated to providing services to user programs? a.) Program execution b.) Resource allocation c.) Communication
Resource Allocation
____ is not one of the major categories of system calls.
Security
When a process creates a new process using the fork() operation, which of the following states is shared between the parent process and the child process? a.) Stack b.) Heap c.) Shared memory segments
Shared memory segments