Operating Sys Final Flashcards

1
Q

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?

A

/home/Lisa/2019/doc

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What command would tell us the number of files that begin with the letters ‘sc’ in our parent directory?

A

ls -l ../sc* | wc -l

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the command that could be used to get information about sfdisk command?

A

man sfdisk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

rw-

They can read the file
They can write the file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command identifies the last 5 occurrences of the word “prince” in the file hamlet.txt?

A

grep -e “prince” hamlet/txt | tail -n 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What will the permission on the file file1.sh be after executing the following command?

chmod 445 file1.sh

A

r–r–r-x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a system bus?

A

it is the part of the data bus connects data transfers between RAM and the CPU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How many megabytes in a gigabyte?

A

There are 1,024 megabytes in a gigabyte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a rootkit?

A

A rootkit is a malicious software program designed to give attackers unauthorized access and control over a computer system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an interrupt service routine?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are facts about ISRs?

A
  • they are the same as interrupt handlers
  • there are as many of them as there are potential interrupt sources
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the primary reason for having interrupts?

A

they eliminate CPU busy-waits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the process of making a system call

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Arrange from least to greatest( 1 = least, 4 = greatest):

__ 0.0038 kilo seconds
__ 38,000 milliseconds
__ 0.38 seconds
__ 38,000 microseconds

A

3 0.0038 kilo seconds
4 38,000 milliseconds
2 0.38 seconds
1 38,000 microseconds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What command correctly counts the number of words in the 50 lines of the file othello.txt starting at line 1000?

A

head -1050 Othello.txt | tail -50 | wc -w

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the output of the second pwd command below?

$pwd
/users/home/dan/documents
$ cd ..
$pwd

A

/users/home/dan

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the UNIX command that allows a user to terminate a process based on a Process ID (PID)?

A

pkill PID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The core (or the “brain”) of the Operating System is called ____.

A

Kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

For a MIPS CPU, which subsystem would execute a lw or sw instrution?

A

the MMU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How many micrograms are in a kilogram

A

10^9 or 1,000,000,000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Which subsystem of a CPU administers the instruction cycle?

A

the Control unit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

List the three phases of a CPU’s instruction cycle.

A

Fetch, Decode, Execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a dual-mode CPU? What is the difference between the two modes?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is POSIX?

A

it is a standard API for making system calls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Briefly describe the system bus. What does it do? How does it work?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is the primary vehicle for moving data from the CPU to a peripheral device?

A

the system bus

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

List four main areas of concern for operating systems

A
  1. Process management
  2. Device management
  3. File management
  4. Memory management
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

The central process of an operating system is called

A

the kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is the primary consumer of O/S services?

A

programs that run on the computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

What best describes the use of a pipe (|) between shell commands?

A

It redirects the output of each command to the input of the next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

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

A

ls -s | head -n -3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

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

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

What is a Trap?

A

an instruction that switches CPU modes

34
Q

Software that emulates the physical hardware of an entire computer system is called ___ ?

A

a virtualization engine

35
Q

What is not part of the operating system?

A
  • compilers
  • the graphical user interface
36
Q

What of the CPU’s subsystem might execute a decoded instruction?

A
  • the memory management unit
  • the ALU
37
Q

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?

A

the current directory is not in the search path

38
Q

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 &laquo_space;w;

return 0;
}

A

w = 19

Note -> 0 and -1 is an error

39
Q

Consider the main() function declaration below

int main (int arc, char *argv[])

which best describes the argument argv?

A

it is a list of arguments passed to the program

40
Q

Which is a reasonable time quantum for a scheduled process to run?

A

70 miliseconds

41
Q

When a running process wishes to start a new thread of a execution, which of the following system calls is used?

A

pthread_create()

42
Q

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?

A

system B

43
Q

On a certain desktop computer, the system monitoring utilization is at 7.3%. Which of the following is likely true?

A

there are mostly I/O bound processes running on the system

44
Q

The list of processes waiting on a particular I/O device is called a(n) ___.

A

device queue

45
Q

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

A

the process controls block is full

Process control block includes: PID, STACK, HEAP, TIME SLICE

46
Q

Explain the concept of context-switching

A

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

47
Q

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?

A

system B has the potential to do more work than system A

system B will be less responsive to a user than system A

48
Q

Which of the following is true of the execv() function

A
  • it is used by a process to change its program image
  • it is typically used by a newly forked process
49
Q

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]

A

myFile.txt

50
Q

Discuss the process state diagram. Be explicit about each state and under what conditions each state transition might occurs.

A

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

51
Q

A multithreaded application needs to fetch data from disk. Which is most likely to happen next?

A

The thread repeatedly calls the usleep() function while waiting for the data

52
Q

What is true of thread time-slices?

A

they are never longer than the process time-slice

they involve a context switch

53
Q

Two threads are attempting to simultaneously access a shared resource. The type of problems that could result from such a situation are called

A

concurrencies

54
Q

What best describes the use of the pthread_yield() function?

A

It is used when a running thread wishes to give up the balance of its tieme slice

55
Q

Which of the following are true of the threads?

A

one process can have multiple threads

a process has to have at least one thread

56
Q

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?

A

It could be either:

  • 100 (one decrements and the other increments)
  • 90 (one decrements first)

-110 (one increments first)

57
Q

A race condition ____.

A

results when several threads try to access the same data concurrently

58
Q

When a running process time slice expires, that process moves into which state?

A

ready

59
Q

A running process that needs to fetch data from disk is most likely to end up in which state:

A

waiting

60
Q

How many virtual CPU’s can a system with a single physical CPU have?

A

there is no theoretical limit

61
Q

Under what conditions must scheduling decision need to be made?

A
  • running process terminates
  • the running process time slice expires
62
Q

What is priority inversion?

A

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.

63
Q

What is deadlock? How does it happen?

A

Deadlock is a situation where two or more processes (or threads) are blocked forever, waiting for resources that are held by each other.

64
Q

what is critical region?

A

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.

65
Q

How can critical regions be used with mutex and/or semaphores t conditions

A

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.

66
Q

What is difference between mutex/semaphores?

A
  • 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.

67
Q

What is a Mutex? What are the steps to implement mutex?

A
  • 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.
68
Q

What is a semaphore and what are the steps to implement mutex and the semaphore functions?

A
  • 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.
69
Q

What are 3 items specific to threads

A

Items Specific to Threads:
- Thread ID (TID)
- Stack
- Register set

70
Q

What are 3 items specific to processes

A

Items Specific to Processes:
- Process ID (PID)
- Address space
- Process control block (PCB)

71
Q

Describe how spin lock works?

A

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.

72
Q

What are two problems with the sleeping barber?

A

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

73
Q

What does execv() do?

A

it is used by a process to change its program image

it is typically used by a newly forked process

74
Q

Describe how sleeping barber problem?

A

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.

75
Q

What does the execv() function o?

A

execv (or variants like execl, execlp) replaces the current process image with a new program. The specified program is loaded and starts execution.

76
Q

What is a multi threaded application?

A

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.

77
Q

What is context switching?

A

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.

78
Q

What is a time quantum?

A

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.

79
Q

What is forking?

A

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.

80
Q

What are the alternative representations of read, write, and execute for file and directory permissions ?

A

Numbers provide an alternative representation:

4 (read)
2 (write)
1 (execute)

Permissions are combined using addition (e.g., 7 = rwx for full access).