Академический Документы
Профессиональный Документы
Культура Документы
Program/software that communicates user and hardware that allows the user
to use a computer
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.
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
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
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.
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
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.