quizzes and ppt Flashcards
What types of sockets are typically used for communication within the same machine?
Stream sockets
What is the default action when a process receives the SIGINT signal?
Terminate the process
When might a developer choose to use SIGUSR1 and SIGUSR2 signals for interprocess communication?
To request a process to perform a specific action or task
What is the primary purpose of standard I/O streams in C programming?
To provide an abstraction for file descriptors and buffers
In the write() function, what does the count parameter represent?
The maximum number of bytes to append to the end of the pipe
What does it mean when it’s mentioned that dup2() performs the operation “atomically”?
There is no time lapse between closing newfd and duplicating oldfd into its spot
Which protocol is commonly used for communication over the internet using sockets?
TCP/IP
You have an IP address represented as 127.0.0.1 (IPv4) in a human-readable format. Which of the following options correctly represents this IP address in network byte order using the htonl() function in C?
0x0100007F
0x7F000001
0x00000001
0x7F000000
0x7F000001
In a C program, what does a socket address typically look like when combining an IP address and a port number?
A structure, e.g., struct sockaddr_in
Identify the function and whether it belongs to the server side process or client side process
recvfrom()
bind()
connect()
accept()
listen()
socket()
recvfrom()
both server side and client side
bind()
server side
connect()
client side
accept()
server side
listen()
server side
socket()
both server side and client side
Process Control Block (PCB) contains the following information related to a process
Process ID
Program Counter
Process Priority
List of open files
When a process places an I/O request, it is placed in the
I/O Queue
include <stdio.h></stdio.h>
Considering you don’t have an overloaded machine, how many times will this code print hello :
#include <sys/types.h>
#include <unistd.h>
int main()
{
fork();
fork();
fork();
printf("hello\n");
return 0;
}</unistd.h>
8
fork() returns a 0 on failure
False
wait() or sleep() functions can introduce synchronization between concurrently executing processes
true
Signals can be generated from these sources.
hardware, keyboard and C program
When a system call is made, the CPU will run in _____________ mode
kernel
Choose the modes of opening a file
O_RDONLY
O_RDWR
O_WRONLY
This is a collection of memory locations that a process can access.
virtual address space
In UNIX/LINUX the file descriptor associated with your monitor or screen or the standard output is ___________
1
Match the different sections of a process’s user-level context with the corresponding data stored
text
data
heap
stack
text
source code
data
static and global variables initialized at runtime
heap
dynamic memory allocated at runtime
stack
return addresses, function parameters, variables etc
What is stored in a register during a context switch for a register-level context in processes?
The program counter (PC) and some processor status flags
What is the primary advantage of using threads in a multi-threaded application?
Threads allow for concurrent execution and better resource utilization
Which of the following is true about thread synchronization?
Thread synchronization is used to ensure that threads do not interfere with each other when accessing shared resources
A condition variable is used to wait until a particular condition is true. Condition variables must be used in conjunction with a mutex lock.
true
Suppose P, Q and R are co-operating processes satisfying Mutual Exclusion condition. If the process Q is executing in its critical section then, ……………..
‘P’ does not executes in critical section
‘R’ does not executes in critical section
Which are true of the (counting) semaphore operation called “wait()”?
it decrements the value of the semaphore
if the value becomes negative, the calling process is blocked
A lower-level mutual exclusion mechanism is needed, to ensure that the fetching and storing of the semaphore value are done atomically.
Which of the following are true of the pthread_mutex_lock() operation?
it takes a reference to a mutex as a parameter
it is intended to provide mutual exclusion
If one thread of a process is holding the lock on a mutex, and another thread of the process attempts to lock the mutex, the whole process is blocked. (t/f)
false
In a system that supports multithreaded processes, which of the following are likely to be associated with an individual thread (i.e., different for different threads within the process)?
Execution state (running, ready, etc.)
Saved context (when not running)
Execution stack
Set of accessible open files
Because the thread scheduling algorithm can swap between threads at any time, you must program the order in which the threads will attempt to access the shared data (t/f)
false
A “strong” semaphore is one that always achieves mutual exclusion. (t/f)
true
Match the following
Counting Mechanism for Resource Allocation
Used to Coordinate Threads’ Execution
Non-deterministic events
Threads make no progress because of this circular chain of dependency mechanism
An atomic increment and decrement operation is
Counting Mechanism for Resource Allocation
Semaphore
Used to Coordinate Threads’ Execution
Condition variables
Non-deterministic events
Spurious wakeup
Threads make no progress because of this circular chain of dependency mechanism
Deadlock
An atomic increment and decrement operation is
Thread-safe
Say the critical section is protected by the exitSemaphore. When a thread finishes its critical section, it signals this by calling sem_post(&exitSemaphore) (t/f)
true