0% found this document useful (0 votes)
25 views11 pages

Quizz OS

Uploaded by

hail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views11 pages

Quizz OS

Uploaded by

hail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

I.

General
Question 1
----------
Regarding threads
A user kernel thread which blocks will block other kernel level
threads in the same process
Two kernel level threads can run on different processors

Question 2
----------
In a memory management system, the most accurate replacement
strategy is:
LRU

Question 3
----------
The execvp() function
Create a process which executes a binary
Execute a binary and then returns to the previous one

II. Process
Question 1
----------
The kill bash command is used for
killing a process (+10)
sending a signal to a process (-10)
stopping a process (-10)
resuming a process (-10)

Question 2
----------
When the shell has to execute a command (with its parameters) stored
in a "char *argv[]" table, you can use:
execl() (-5)
execv() (+5)
execlp() (-5)
execvp() (+5)

Question 3
----------
In a Linux system, scheduling allows to execute
several processes on the same core (+5)
several processes on multiple cores (+5)
only one process per core (-5)
one process on multiple cores at the same time (-5)
Question 4
----------
The fork() function
returns 0 to the father process (-5)
returns 0 to the child process (+5)
returns the pid of the child to the father process (+5)
returns the pid of the child to the child process (-5)

Question 5
----------
After a call to fork(), the child process
shares the address space of the father (-5)
has a copy of the address space of the father (+5)
has the same opened file descriptors as the father (+5)
has no opened file descriptors (-5)

Question 6
----------
When we execute the following program :
fork(); fork();
how many processes are created (including the one which executes the
main())
3 (-10)
4 (+10)
5 (-10)
6 (-10)

Question 7
----------
When we run an application foo (which takes 3 parameters from the
command line) from a shell : ./foo p1 p2 p3
In the main of the foo program, argv is :
{"p1", "p2", "p3"} (-10)
{"foo", "p1", "p2", "p3"} (+10)
{"foo", "foo", "p1", "p2", "p3"} (-10)

Question 8
-----------
The kill() function
can be used to kill a process (+5)
can be used to send a signal (+5)
can be used to remove a user (-5)
can be used to shutdown the machine (-5)

Question 9
-----------
When you type ‘ls’ in the shell, what happens if you don’t call
waitpid() before looping and printing the prompt
The prompt can be print before or after the output of ls
The prompt can be printed in the middle of the output of ls

Question 10
-----------
When you type ‘ls’ in the shell, what happens if you don't call
fork() before execvp()
Ls is executed
The shell terminate after the execution of ls

Question 11
----------
In the readme.c module in the “struct cmdline” structure, the “char
***seq” filed is:
A table of tables of strings including several commands and para

Question 12
----------
When you create a pipe p
Communiacation goes from p[1] to p[0]
You can write on p[1]

Question 13
----------
After a dup2(p[0[, 0);
You must close(p[0]);

Question 14
----------
When you type “ls” in a shell such as bash
Ls is executed by a new process
The binary code of ls is in a separate binary

Question 15
----------
In the main loop of a shell you have generally:
A fork() and then a waitpid()

Question 16
----------
In the following code we want data from A to redirected to B. What
should be the….
Xxx = (p[1], 1)
Yyy = (p[0], 0)

III. IPC Sched


Question 1
----------
The dup2(oldfd, newfd) function
redirect IO on oldfd so that they are performed on newfd (-5)
redirect IO on newfd so that they are performed on oldfd (+5)
copies the file descriptor oldfd into the file descriptor newfd (+5)
copies the file descriptor newfd into the file descriptor oldfd (-5)

Question 2
----------
If I call dup2(fd,0) with fd being an opened file
everything read from STDIN is written to the file (_5)
everything read from STDIN is read from the file (+5)
the file shoud be opened in read mode (+5)
the file should be opened in write mode (-5)

Question 3
----------
When you create a pipe p
communication goes from p[1] to p[0] (+5)
communication goes from p[0] to p[1] (-5)
you can read from p[0] (+5)
you can read from p[1] (-5)

Question 4
----------
After a dup2(p[0], 0);
you must close(p[0]); (+10)
you must close(0); (-10)
you don't have to close anything (-10)

Question 5
----------
The shmat() function
allow to create a shared memory segment (-10)
allow to attach a shared memory segment in an address space (+10)
allow to find the location of a shared memory segment (-10)

Question 6
----------
with a pipe p, if p is empty
write(p[0] ...) will block (-10)
write(p[1] ...) will block (-10)
read(p[0] ...) will block (+10)
read(p[1] ...) will block (-10)

Question 7
----------
with a pipe p, if p is full
write(p[0] ...) will block (-10)
write(p[1] ...) will block (+10)
read(p[0] ...) will block (-10)
read(p[1] ...) will block (-10)

Question 8
----------
threading allow
to execute several threads in one process (+5)
to execute one thread in several processes (-5)
to share the process address space between several threads (+5)
to execute each thread within a private address space (-5)
IV. Synchronization
Question 1
----------
In the reader/writer synchronization scheme, when some processes are
reading
a new writer can write (-5)
a new writer cannot write (+5)
a new reader can read (+5)
a new reader cannot read (-5)

Question 2
----------
In the reader/writer synchronization scheme, when a process is
writing
a new writer can write (-5)
a new writer cannot write (+5)
a new reader can read (-5)
a new reader cannot read (+5)

Question 3
----------
With Posix monitors, when you call pthread_cond_signal(&condition);
the next thread which calls pthread_cond_wait() on the condition
will not block (-5)
one thread which is blocked on the condition is resumed (+5)
if no thread is blocked on the condition, nothing happens and the
signal is lost (+5)
all the threads which are blocked on the condition are resumed (-5)

Question 4
----------
With semaphores, the P() function
suspends the calling process if the counter is positive (-5)
suspends the calling process if the counter is negative (+5)
increments the counter (-5)
decrements the counter (+5)

Question 5
----------
In a Posix monitor, what happens if we don't use the mutex lock ?
the executing thread can block (-5)
the shared data may become unconsistent (+5)
we can have a deadlock (-5)
all the threads can access the shared data at the same time (+5)
Question 6
----------
In the prodcons labwork with the products and freeslots conditions
possibly no threads are blocked on any of the two conditions (+5)
possibly threads are blocked on both conditions (-5)
if threads are blocked, they are all blocked on the same condition
(+5)
a thread can block at the same time on both conditions (-5)

Question 7
----------
In the prodcons labwork, the buffer will be most of the time
empty if we create more producer threads (-5)
full if we create more producer threads (+5)
empty if we create more consumer threads (+5)
full if we create more consumer threads (-5)

Question 8
----------
In the prodcons labwork with the products and freeslots conditions,
if I produce, I must:
test if the buffer is empty (-5)
test if the buffer is full (+5)
possibly block on the freeslots condition (+5)
possibly block on the products condition (-5)

Question 9
----------
If we have 2 threads respectively executing the 2 following
routines:

What are the possible execution traces


Hello2 hello1 world1 world2
Hello1 hello2 world1 world2

Question 10
----------
When you call pthread_cond_signal(&condition);
One thread which is blocked on the condition is resumed
If no thread is blocked on the condition, nothing happens and the
signal is lost
Question 11
----------
In the prodcons labwork, what happens if we dont use the mutex lock?
All the threads can access the shared data at the same time
The shared data can become unconsistent

Question 12
----------
In the prodcons labwork with the products and freeslots condition,
if the buffer is full
The next produce will block on the free slots condition

Question 13
----------
When you call pthread_cond_wait(&condition, &mutex);
The second parameter (mutex) is passed to release the mutex

Question 14
----------
In the prodcons labwork with the products and freeslots conditions,
if the buffer is empty
The next consume will block on the products condition

Question 15
----------
In the prodcons labwork with the products and freeslots conditions,
if I consume, I must:
Test if the buffer is empty
Possibly block on the products condition

Question 16
----------
In the prodcons labwork with the products and freeslots condition
If threads are blocked, they are all blocked on the same condition
Possibly no threads are blocked on any of the 2 conditions
V. Memory
Question 1
----------
The LRU eviction strategy
is used to make space available in main memory (+5)
is used to make space available on disk (-5)
selects the pages which should be sent to disk (+5)
selects the pages which should be loaded from disk (-5)

Question 2
----------
When a page fault occurs
this is because memory is full (-10)
this is because memory is empty (-10)
this is because the page is in memory (-10)
this is because the page is not in memory (+10)

Question 3
----------
When a page fault occurs
a page will always be loaded (+5)
a page will always be sent to disk (-5)
there will always be a LRU selection (-5)
there will possibly be a LRU selection (+5)

Question 4
----------
When a page is selected by LRU for replacement
this page must be loaded in memory (-10)
this page must be sent to disk (+10)

Question 5
----------
When a page is selected by LRU for replacement
this page can still be accessed (-10)
this page must be invalidated in the page table (+10)
Question 6
----------
When a page fault occurs, if memory is not full
a page will be allocated in memory (+5)
a LRU selection will be operated (-5)
a page will be loaded from disk (+5)
a page will be sent to disk (-5)

Question 7
----------
the principle of the working-set is that
90% of page accesses fit in 10% of the memory (+10)
10% of page accesses fit in 90% of the memory (-10)
10% of page accesses fit in 10% of the memory (-10)
90% of page accesses fit in 90% of the memory (-10)

Question 8
----------
The goal of the LRU page eviction strategy is to
keep the working-set in memory (+5)
send the working-set to disk (-5)
keep Least Recently Used pages in memory (-5)
send Least Recently Used pages to disk (+5)

Question 9
----------
When a page faults occurs, if memory is not full
A page will be loaded from disk
A page will be allocated in memory

Question 10
----------
In the memory labwork, the implementation of lru_select()
Looks for the page with the minimal access date

Question 11
----------
The LRU eviction strategy consists in
Selecting the pages which were not recently accessed
Choosing the pages which should be sent to disk

You might also like