Operating Sys Final Flashcards
Consider the following terminal transaction:
$ cd/home/Lisa/2019/mail/sent
$cd ../../doc
$pwd
Assuming none of the commas generates an error, what will be the result following the last command?
/home/Lisa/2019/doc
What command would tell us the number of files that begin with the letters ‘sc’ in our parent directory?
ls -l ../sc* | wc -l
What is the command that could be used to get information about sfdisk command?
man sfdisk
Consider the following entry in a long director listing (ls -l)
-rwxrw-r-x 1 paula staff 15020 Feb 13 2017 myFile.txt
what privileges do members of paula’s group have on this file?
rw-
They can read the file
They can write the file
What command identifies the last 5 occurrences of the word “prince” in the file hamlet.txt?
grep -e “prince” hamlet/txt | tail -n 5
What will the permission on the file file1.sh be after executing the following command?
chmod 445 file1.sh
r–r–r-x
What is a system bus?
it is the part of the data bus connects data transfers between RAM and the CPU
How many megabytes in a gigabyte?
There are 1,024 megabytes in a gigabyte
What is a rootkit?
A rootkit is a malicious software program designed to give attackers unauthorized access and control over a computer system.
What is an interrupt service routine?
An ISR(interrupt service rountine) is a routine that sends out a signal (a internet) when a event takes place that needs the CPU’s immediate attention
What are facts about ISRs?
- they are the same as interrupt handlers
- there are as many of them as there are potential interrupt sources
What is the primary reason for having interrupts?
they eliminate CPU busy-waits
Describe the process of making a system call
- program sends TRAP instruction
- operating system switches from user mode to kernel mode
- does instructions
- operating sys switches from kernel mode to user mode
- control is given back to the program
Arrange from least to greatest( 1 = least, 4 = greatest):
__ 0.0038 kilo seconds
__ 38,000 milliseconds
__ 0.38 seconds
__ 38,000 microseconds
3 0.0038 kilo seconds
4 38,000 milliseconds
2 0.38 seconds
1 38,000 microseconds
What command correctly counts the number of words in the 50 lines of the file othello.txt starting at line 1000?
head -1050 Othello.txt | tail -50 | wc -w
What is the output of the second pwd command below?
$pwd
/users/home/dan/documents
$ cd ..
$pwd
/users/home/dan
What is the UNIX command that allows a user to terminate a process based on a Process ID (PID)?
pkill PID
The core (or the “brain”) of the Operating System is called ____.
Kernel
For a MIPS CPU, which subsystem would execute a lw or sw instrution?
the MMU
How many micrograms are in a kilogram
10^9 or 1,000,000,000
Which subsystem of a CPU administers the instruction cycle?
the Control unit
List the three phases of a CPU’s instruction cycle.
Fetch, Decode, Execute
What is a dual-mode CPU? What is the difference between the two modes?
- A dual-mode CPU is a system that has two modes kernel mode and user mode
- Kernel mode has unrestricted privileges
User mode has limited privileges
What is POSIX?
it is a standard API for making system calls
Briefly describe the system bus. What does it do? How does it work?
The system bus connects the CPU, I/O devices, memory and other devices together. It transmites data and instructions between them. There are three buses to make this work
Data Bus: Carries data between the CPU, memory, and I/O devices.
Address Bus: Transmits the physical location (address) of data to be accessed or written by the CPU.
Control Bus: Transfers control signals for coordinating the overall system’s operation.
What is the primary vehicle for moving data from the CPU to a peripheral device?
the system bus
List four main areas of concern for operating systems
- Process management
- Device management
- File management
- Memory management
The central process of an operating system is called
the kernel
What is the primary consumer of O/S services?
programs that run on the computer
What best describes the use of a pipe (|) between shell commands?
It redirects the output of each command to the input of the next
The shell command ‘ls -s’ lists files in the current directory by size order, in descending order. Use this knowledge to write a compound shell command that lists the 3 largest files in the current directory
ls -s | head -n -3
Relate each hardware component on the left to its O/S abstraction on the right
[A] CPU [ ] Virtual Memory
[B] Memory [ ] Filesystems
-Mapped I/O Devices
[C] RAM [ ] Process and Threads
[D] Hardware [ ] Peripheral device abstraction
What is a Trap?
an instruction that switches CPU modes
Software that emulates the physical hardware of an entire computer system is called ___ ?
a virtualization engine
What is not part of the operating system?
- compilers
- the graphical user interface
What of the CPU’s subsystem might execute a decoded instruction?
- the memory management unit
- the ALU
Sara compiled her c++ program and successfully created an executable named.out. When she attempted to run the program as shown below, she received an error:
$ a.out
a.out: command not found
$
What is most likely the reason for this error?
the current directory is not in the search path
What is the output of the present process from the code segment below?
int main()
{
int w;
pid_t t;
t = fork();
w = 18;
if (t == 0)
w++;
else
w -= 2;
w += 3
cout «_space;w;
return 0;
}
w = 19
Note -> 0 and -1 is an error
Consider the main() function declaration below
int main (int arc, char *argv[])
which best describes the argument argv?
it is a list of arguments passed to the program
Which is a reasonable time quantum for a scheduled process to run?
70 miliseconds
When a running process wishes to start a new thread of a execution, which of the following system calls is used?
pthread_create()
Two systems are each running several dozen process. On system A, the process tend to be CPU-bound. On system B, the process tends to be I/O bound. Which system is likely to experience the higher rate of context switching?
system B
On a certain desktop computer, the system monitoring utilization is at 7.3%. Which of the following is likely true?
there are mostly I/O bound processes running on the system
The list of processes waiting on a particular I/O device is called a(n) ___.
device queue
A rogue process attempts to replicate itself an infinite number of time through the use of fork(). At some point, the process is no longer able to fork new children. This is mostly likely because
the process controls block is full
Process control block includes: PID, STACK, HEAP, TIME SLICE
Explain the concept of context-switching
The concept of connect switching is to Gove the illusion of multitasking by rapidly switching processes. It saves the current state and loads a new program
Two systems with identical hardware are running similar operating systems. On system A, the time slice are half as long as the ones on system B. What is most likley true?
system B has the potential to do more work than system A
system B will be less responsive to a user than system A
Which of the following is true of the execv() function
- it is used by a process to change its program image
- it is typically used by a newly forked process
The executable myExe is launched from the command line with the following command:
$ myExe -f myFile.txt -u
For this invocation of myExe, what will be the value of argv[2]
myFile.txt
Discuss the process state diagram. Be explicit about each state and under what conditions each state transition might occurs.
1 -> ( New - Ready) -> New process is ready and in ready queue
2 -> (Ready -> Running) -> Scheduler picks process for execution
3 -> (Running -> Ready) -> Time sliced could have expired
4 -> (Running -> Waiting) -> Interrupt occurred; could be waiting on a I/O device
5 -> (waiting -> ready) -> Process is in ready queue
A multithreaded application needs to fetch data from disk. Which is most likely to happen next?
The thread repeatedly calls the usleep() function while waiting for the data
What is true of thread time-slices?
they are never longer than the process time-slice
they involve a context switch
Two threads are attempting to simultaneously access a shared resource. The type of problems that could result from such a situation are called
concurrencies
What best describes the use of the pthread_yield() function?
It is used when a running thread wishes to give up the balance of its tieme slice
Which of the following are true of the threads?
one process can have multiple threads
a process has to have at least one thread
The value of a certain variable x is currently 100. Two threads are attempting to change the value of x. Thread A attempts to increment x by 10. Thread B attempts to decrement x by 10. Which of these is a possible resultant of x?
It could be either:
- 100 (one decrements and the other increments)
- 90 (one decrements first)
-110 (one increments first)
A race condition ____.
results when several threads try to access the same data concurrently
When a running process time slice expires, that process moves into which state?
ready
A running process that needs to fetch data from disk is most likely to end up in which state:
waiting
How many virtual CPU’s can a system with a single physical CPU have?
there is no theoretical limit
Under what conditions must scheduling decision need to be made?
- running process terminates
- the running process time slice expires
What is priority inversion?
A priority inversion occurs when a low-
priority process holds a lock or resource
needed by a high-priority process. The
high priority process blocks, allowing the
low priority process to execute until the
lock is released. Thus, the low-priority
process executes ahead of the high-
priority process.
What is deadlock? How does it happen?
Deadlock is a situation where two or more processes (or threads) are blocked forever, waiting for resources that are held by each other.
what is critical region?
A critical region is a section of code that accesses shared resources and must be executed by only one thread at a time to avoid race conditions.
How can critical regions be used with mutex and/or semaphores t conditions
Mutexes and semaphores can be used to synchronize access to critical regions. A thread acquires the lock (mutex) or decrements the semaphore before entering the critical region, and releases the lock (mutex) or increments the semaphore after exiting. This ensures that only one thread can be in the critical region at a time.
What is difference between mutex/semaphores?
- Mutex: Ensures exclusive access (binary semaphore, value 0 or 1).
- Semaphore: Can allow for concurrent access with a value greater than 1.
-Mutexes are typically used for protecting critical sections, while semaphores have a wider range of applicability for signaling and resource management.
What is a Mutex? What are the steps to implement mutex?
- Mutexes (Mutual Exclusion): A mutex guarantees exclusive access to a critical section of code. Only one thread can acquire the mutex at a time. Steps to implement mutexes and mutex functions typically involve system calls provided by the operating system.
What is a semaphore and what are the steps to implement mutex and the semaphore functions?
- Semaphores: A semaphore is a synchronization tool that can be used for signaling events and controlling access to shared resources. Semaphores can have a value greater than 1, allowing multiple threads to access the resource concurrently up to the semaphore’s limit.
- Similar to mutexes, semaphore implementation and functions rely on system calls.
What are 3 items specific to threads
Items Specific to Threads:
- Thread ID (TID)
- Stack
- Register set
What are 3 items specific to processes
Items Specific to Processes:
- Process ID (PID)
- Address space
- Process control block (PCB)
Describe how spin lock works?
Spin locks are a type of synchronization mechanism where a thread trying to acquire a lock keeps checking (spinning) until the lock becomes available. This can be inefficient if the lock is held for a long time.
What are two problems with the sleeping barber?
Busy Waiting: Waiting barbers constantly check if a customer arrives (inefficient).
Starvation: A customer might wait indefinitely if the barber is always busy cutting hair for another customer
What does execv() do?
it is used by a process to change its program image
it is typically used by a newly forked process
Describe how sleeping barber problem?
The sleeping barber problem is a classic synchronization problem that demonstrates the need for semaphores to coordinate access to shared resources. It involves a barber, chairs, and waiting customers.
What does the execv() function o?
execv (or variants like execl, execlp) replaces the current process image with a new program. The specified program is loaded and starts execution.
What is a multi threaded application?
A multithreaded application is a program that contains multiple threads of execution. Threads share the same memory space and resources of the process but can be scheduled independently.
What is context switching?
Context switching is the process of saving the state of the current running process and loading the state of another process to allow it to run on the CPU.
What is a time quantum?
In a multiprogramming environment, the time quantum is a fixed amount of time allocated to a process by the CPU scheduler. It ensures fairer sharing of CPU resources among multiple processes.
What is forking?
Forking is a process creation mechanism where a new process is created that is a replica of the calling process.
The number of processes created is two: the parent process and the child process.
What are the alternative representations of read, write, and execute for file and directory permissions ?
Numbers provide an alternative representation:
4 (read)
2 (write)
1 (execute)
Permissions are combined using addition (e.g., 7 = rwx for full access).