Вы находитесь на странице: 1из 5

1. (5 points) What is an operating system?

Program/software that communicates user and hardware that allows the user
to use a computer

Kernel Mode: commands only given by OS to hardware


User Mode: commands any program/application can give to hardware
Dual Mode: Kernel and User Mode by using a mode bit

2. (15 points) Name the main functions of OS:


Running/executing Programs
CPU management
RAM management
Storage management
I/O devices
Networking
User Interface
Security

3. (15 points) What is system call? What for do we need system calls? Why
simple computer commands are not enough?
System call is when program asks the OS to run a kernel command/action for
the program. Simple computer commands are not enough since some
programs are not safe or has no access to it.

4. (10 points) What is Process Control Block? What kind of information is


stored in it?
Process Control block is a data structure that contains pertinent information
about the process it is serving in RAM. PCB includes process ID, process
state, CPU scheduling, process CPU register, I/O device info, registers and
pointers.

5. (15 points) State four different reasons why process that is currently
executed by CPU can leave CPU.
-context switch: program was switched out by user
-exit() process terminates/completes
-interrupts process is terminated by event in hardware
-cascading termination child process terminates along with parent
-time out

6. (15 points) How many stars will be displayed if the following code is
executed?
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
pid_t pid;
pid=fork();
if(pid==0)
{
fork();
fork();
printf(*);
}
return 0;
}
4 stars

7. (10 points) Name two main mechanisms of interprocess communication


(IPC). What are advantages and disadvantages of each mechanism?
Shared memory
Message passing: Direct communication(recipient and sender), Indirect
communication(mailboxes and ports), Synchronous communication (pauses
execution until message received and confirmation sent) and Asynchronous
communication (continues to execute)

Advantages: Shared memory is fast since it only needs kernel to share


memory. Memory passing is secure/safe.
Disadvantages: Shared memory is not secure/safe (read/write problems).
Memory passing is slow, Halting Problem, and requires kernel command.

8. (15 points) What are the advantages of creating different threads instead
of creating different processes? What are the advantages of using processes
(or, to put it the other way, what are the limitations of threads)?
Thread is basic unit of CPU utilization
Break up the process load(parallelism) and share memory
context switch is time costly while threads share memory which is less costly
Dependencies: one thread can stomp on another thread's data. If one thread
blocks, all threads block

Kernel uses a scheduler to manage kernel level threads


Kernel is not aware of user level threads

9. (10 points) What is Thread Local Storage (TLC)?


Computer programming method that uses static on global memory local to a
thread. TLS is used in some places where ordinary, single-threaded programs
would use global variables but where this would inappropriate in multithread
cases.
3. (15 points) What is an interrupt? What for do we need interrupts?
A signal from device attached to computer(hardware) of from program within
computer(software) that causes the operating system to stop and figure out
what to do next utilizing the interrupt handler, vector and queue. It will not
continue until it is resolved. Almost all computers are interrupt-driven. They
keep running instructions until they cant go any further or an interrupt
signal is sensed. After interrupt signal is sensed, until it is resolved, the
computer either resumes running the program it was running or begins
running another program.

4. (10 points) What is Context switch?


Switching of CPU from one process or thread to another while ensuring that
the tasks do not conflict. Effective context switching is crucial is a computer
is to provide user friendly multitasking. A modern CPU can perform hundreds
of context switches per second. It can only be done in kernel mode.

5. What is ready queue? What is I/O queue? How many ready queues and I/O
queues you expect to have in a multiprocess system?
Ready Queue is a list of all processes that are waiting to be scheduled on a
core/CPU.
I/O queue is a list of processes waiting for a particular I/O device. Each
device has its own device queue.
There is one ready queue per processor core and one I/O queue for each I/O
device.

6. (15 points) How many stars will be displayed if the following code is
executed?
5 stars

7. (5 points) Mark which of the following memory sections will NOT be shared
by different threads of the same process:
shared text section
not shared stack (each thread has its own stack)
shared data section
shared heap

8. (15 points) What is thread pool? What are the advantages of using thread
pools?
Collection of worker threads that efficiently execute asynchronous callbacks
on behalf of the application. Thread pools are primarily used to reduce the
number of application threads and provide management of worker threads.
A thread pool is pre-instantiated, idle threads which stand ready to be given
work. These are preferred over instantiating new threads for each task when
there is a large number of short tasks to be done rather than a small number
of longs ones. This prevents having to incur the over head of creating a
thread large number of times. Efficiency and speed.

9. (15 points) What is a networking port? What are the well-known


networking ports and why do we need them?
A Network port is process-specific or an application specific software
construct serving as a communication endpoint of the OS. All network
devices use them.
0-1024 are well known networking ports. Originally created to allow multiple
programs to use the same IP address. Useful for remote access of devices.

Miscellaneous
Multithreading models:

Many-to-One
Many user threads to one kernel thread
Thread Library management of threads
One thread blocks all threads, no parallelism

Many-to-Many
Many user threads to many kernel threads
No restriction of number of threads
Blocking kernel call does not block entire process
Hard to implement, allocation is hard

One-to-One
One user thread per user kernel
No blocking is possible
More overhead management (costly and inefficient) and slows systems
down, thread limit

Parallel Programming: simultaneous use of multiple computer resources to


solve a computational problem.

Task Parallelism: is the simultaneous execution on multiple cores of many different functions
across the same or different datasets. Focuses on distributing tasks performed by processes or
threads across different parallel computing nodes. Ex: pipelining.

Data Parallelism: is the simultaneous execution on multiple cores of the same function across
the elements of a dataset. Focuses on distributing data across different parallel computing
nodes.

Process: instance of a computer program that is to be executed.

Short term scheduling:


Socket: IP and port, endpoint

OpenMP: parallel code

Вам также может понравиться