CYSE questions

Ace your homework & exams now with Quizwiz!

What is the meaning of busy waiting? What other kinds of waiting are there in an operating system? Can busy waiting be avoided all together?

Busy waiting means that a process is waiting for a condition to be satisfied in a loop without relinquishing the processor. It could wait by relinquishing the processor and block on a condition and wait to be awakened. Can be avoided but there is overhead with a process waking and sleeping

What are tertiary storage devices?

Low cost is the defining characteristic of tertiary storage. Generally, tertiary storage is built using removable media Common examples of removable media are floppy disks and CD-ROMs; other types are available

What is magnetic tape?

Was early secondary-storage medium Evolved from open spools to cartridges Relatively permanent and holds large quantities of data Access time slow Random access ~1000 times slower than disk Mainly used for backup, storage of infrequently-used data, transfer medium between systems Kept in spool and wound or rewound past read-write head Once data under head, transfer rates comparable to disk 140MB/sec and greater 200GB to 1.5TB typical storage Common technologies are LTO-{3,4,5} and T10000

How much does a floppy disk hold?

1MB

Are disks removable?

yes

What is the expected return value of the fork() function? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

• In the child process the return value of fork() is 0, so the variable pid = 0 • In the parent process the return value of fork() is the process id of the child process (a positive integer)

What does the fork() function do? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

• It creates an exact copy of the present process in the RAM memory of the system • It creates a new process control block for the new (copied) process • The new process control block is placed in the queue of process control blocks • Both the parent process and the child process continue execution from the return to the fork command to the next operation in the code (the test to determine which line is executed next in line 1)

Is the cloud good for everything?

• No. • Sometimes it is problematic - Auditability requirements - Legislative frameworks • Example: Personal data privacy - EU Data Protection law • Example: Processing medical records (US) - HIPAA (Health Insurance Portability and Accountability Act) privacy and security rule

What were the differences between the child's process control block and the parents process control block that were discussed in class? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

• The Parent and child processes have different process ids • The child has the parents pid as its own pid of parent, while the parent's pid of parent is the pid of the process that created the parent process • The parent adds the pid of the child to its list of process ids of its children.

Are all illustrated lines of code executed by the parent process? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

•NO •Since the return value for the parent process is the pid of the child process, the test in line 1 of the code above is false. •Lines 2, 3 and 4 inside the if are not executed. The next line executed is line 4.

This system has 12 devices. Job 1: Allocated: 5 required: 8 Remaining needed1:? Job 2: Allocated: 1 required: 4 Remaining needed2:? Job 3: Allocated: 5 required: 7 Remaining needed3:? Determine the remaining needs for each job in each system

(required - allocated) (8-5) = 3 (4-1) = 3 (7-5) = 2 3+3+2 = 8 max remaining

Why is cloud computing attractive?

- Analogy to 'classical' utilities (electricity, water, ...) - No up-front investment (pay-as-you-go model) - Low price due to economies of scale - Elasticity: can quickly scale up/down as demand varies

What does the program do? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

- Line 1 of the code begins by executing fork() which creates a copy of the present process. - The copy has its own process control block. - The newly created copy process is the child process; the original process is the parent process. - In the parent process, the return value of the function fork() is the process id of the child process. - in the child process The return value of fork( ) is 0

What is RAID?

- redundant array of inexpensive disks Increases the mean time to failure Mean time to repair - exposure time when another failure could cause data loss Mean time to data loss based on above factors

What are B-trees?

-A balanced tree structure with all branches of equal length -Standard method of organizing indexes for databases -Commonly used in OS file systems -Provides for efficient searching, adding, and deleting of items

What is the difference between a process and a thread. Which one consumes more resources?

-A process defines the address space, text, resources, etc. -A thread defines a single sequential execution stream within a process. -Threads are bound to a single process. -Each process may have multiple threads of control within it. -It's much easier to communicate between threads than between processes. -It's easy for threads to inadvertently disrupt each other since they share the entire address space. -Process consumes more resources

What is the direct/hashed file?

-Access directly any block of a known address -Makes use of hashing on the key value -Often used where: very rapid access is required fixed-length records are used records are always accessed one at a time

What is the indexed sequential file?

-Adds an index to the file to support random access -Adds an overflow file -Greatly reduces the time required to access a single record -Multiple levels of indexing can be used to provide greater efficiency in access

What is the readers/writers lock?

-Allows multiple threads to have simultaneous read-only access to an object protected by the lock -Allows a single thread to access the object for writing at one time, while excluding all readers

What is the basic file system?

-Also referred to as the physical I/O level -Primary interface with the environment outside the computer system -Deals with blocks of data that are exchanged with disk or tape systems -Concerned with the placement of blocks on the secondary storage device -Concerned with buffering blocks in main memory -Considered part of the operating system

What happens when fork() is followed by exec()?

-Creates a new process as clone of previous one -First thing that clone does is to replace itself with new program

What are the problems with the Banker's algorithm?

-Jobs must state maximum number needed resources -Requires constant number of total resources for each class -Number of jobs must remain fixed -Possible high overhead cost incurred -Resources not well utilized Algorithm assumes worst case -Scheduling suffers -Result of poor utilization -Jobs kept waiting for resource allocation

What is the pile file?

-Least complicated form of file organization -Data are collected in the order they arrive -Each record consists of one burst of data -Purpose is simply to accumulate the mass of data and save it -Record access is by exhaustive search

What is the sequential file?

-Most common form of file structure -A fixed format is used for records -Key field uniquely identifies the record -Typically used in batch applications -Only organization that is easily stored on tape as well as disk

What are spinlocks?

-Most common technique for protecting a critical section in Linux -Can only be acquired by one thread at a time any other thread will keep trying (spinning) until it can acquire the lock -Built on an integer location in memory that is checked by each thread before it enters its critical section -Effective in situations where the wait time for acquiring a lock is expected to be very short -Disadvantage: locked-out threads continue to execute in a busy-waiting mode

What are the disadvantages of User level threads?

-Most system calls are blocking and the kernel blocks processes -- So all threads within the process will be blocked -The kernel can only assign processes to processors -- Two threads within the same process cannot run simultaneously on two processors

Is task2 done by the child process? 1. if ( (pid = fork()) == 0 ) { 2. processitInner(); /* function called completes task 1 */ 3. exit (0); 4. } 5. processitOuter(); /* function called completes task 2 */

-No -In the child process the return value of fork() is 0, so pid = 0 • Because pid=0 the condition in the if statement is true • Therefore, execution continues with lines 2 and 3 of the code • After line 3 has executed the child process has terminated, it will never reach line 5 where task 2 is completed.

What is Dijkstra's (Bankers) Algorithm?

-No customer granted loan exceeding bank's total capital -All customers given maximum credit limit -No customer allowed to borrow over limit -Sum of all loans will not exceed bank's total capital

What is access method?

-Provides a standard interface between applications and the file systems and devices that hold the data -Level of the file system closest to the user

What is the indexed file?

-Records are accessed only through their indexes -Variable-length records can be employed -Exhaustive index contains one entry for every record in the main file -Partial index contains entries to records where the field of interest exists -Used mostly in applications where timeliness of information is critical -Examples would be airline reservation systems and inventory control systems

What is the Basic I/O supervisor?

-Responsible for all file I/O initiation and termination -Control structures that deal with device I/O, scheduling, and file status are maintained -Selects the device on which I/O is to be performed -Concerned with scheduling disk and tape accesses to optimize performance -I/O buffers are assigned and secondary memory is allocated at this level -Part of the operating system

What are the advantages of kernel level threads?

-Scheduler may need more time for a process having large number of threads -good for applications that frequently block

Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous was at cylinder 125. The queue of pending requests, in FIFO order, is: 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130 Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests for FCFS, SSTF

-The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. The total seek distance is 7081. -The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774. The total seek distance is 1745.

What is the mutual exclusion (Mutex) Lock?

-Used to ensure only one thread at a time can access the resource protected by the mutex -The thread that locks the mutex must be the one that unlocks it

What are condition variables and what do they need to be used with?

-Used to wait until a particular condition is true -must be used with a mutex lock

How does a removable magnetic disk compare to a hard disk?

-can be nearly as fast -greater risk of damage

What are the B-Tree characteristics?

-every node has at most 2d - 1 keys and 2d children or, equivalently, 2d pointers -every node, except for the root, has at least d - 1 keys and d pointers, as a result, each internal node, except -the root, is at least half full and has at least d children the root has at least 1 key and 2 children -all leaves appear on the same level and contain no information. This is a logical construct to terminate the tree; the actual implementation may differ. -a nonleaf node with k pointers contains k - 1 keys

What are the disadvantages of kernel level threads?

-slow and inefficient -significant overhead

Provide two advantages of threads over multiple processes.

1. Lower overhead of context switch 2. Easier to share data.

steps to use a b tree

1. Search the tree for the key. If the key is not in the tree, then you have reached a node at the lowest level. 2. If this node has fewer than 2 d - 1 keys, then insert the key into this node in the proper sequence. 3. If the node is full (having 2 d - 1 keys), then split this node around its median key into two new nodes with d - 1 keys each and promote the median key to the next higher level, as described in step 4. If the new key has a value less than the median key, insert it into the left-hand new node; otherwise insert it into the right-hand new node. The result is that the original node has been split into two nodes, one with d - 1 keys and one with d keys. 4. The promoted node is inserted into the parent node following the rules of step Therefore, if the parent node is already full, it must be split and its median key promoted to the next highest layer. 5. If the process of promotion reaches the root node and the root node is already full, then insertion again follows the rules of step 3. However, in this case the median key becomes a new root node and the height of the tree increases by 1.

This system has 12 devices. Job 1: Allocated: 5 required: 8 Remaining needed1:? Job 2: Allocated: 1 required: 4 Remaining needed2:? Job 3: Allocated: 5 required: 7 Remaining needed3:? Calculate the number of available devices

12 (total devices) - (5+1+5) (allocated devices) = 1 remaining

What value would the program print? int counter = 1; int main() { if (fork() == 0) { counter--; exit(0); } else { wait(NULL); counter++; printf("counter = %d\n", counter); } exit(0); }

2

How many times would this program print "One" to the display? int main(int argc, char** argv) int i; for (i = 0; i < 2; i++) fork(); printf("One\n"); { printf("Two\n"); }

6

Give a definition of a counting semaphore, and list and describe the valid operations.

: A counting semaphore is a synchronization data structure that can be used to control or limit the number of processes that can access to a critical region. There are three operations that are allowed on a semaphore: 1) Setting the initial value of the semaphore (number of concurrent accesses allowed). 2) P() decrements the semaphore's counter and either causes the process to wait until the resource is available or allocates the process the resource. 3) V() increments the semaphore's counter, releasing a waiting process (if any is waiting).

Consider scheduling of processes and user level threads. Is it possible for the threads in the process to be scheduled onto different processors in a multiprocessor CPU? Briefly explain why.

: NO When user level threads are used the scheduling of threads is managed using the thread library in user space. The OS does not know the specifics of what code it is being run inside the process, it is only aware of system function calls. Since user level threads are part of the code running inside the process, and the user level thread libraries do not make system calls to system level thread system functions the OS is not even aware that the process contains threads. A single process is that does not contain system level threads is always run on a single processor.

Using the following program, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() { pid_t pid, pid1; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ pid1 = getpid(); printf("child: pid = %d",pid); /* A */ printf("child: pid1 = %d",pid1); /* B */ } else { /* parent process */ pid1 = getpid(); printf("parent: pid = %d",pid); /* C */ printf("parent: pid1 = %d",pid1); /* D */ wait(NULL); } return 0; }

:A = 0 B = 2603 C = 2603 D = 2600

How does mac solve trojan?

A Trojan reads a high document and copies its contents to a low file. NO READ UP NO WRITE DOWN

3.What resources are required to create a process?

A new PCB, address space (including page table entries for code, data, a new stack and heap), and copies of all OS bookkeeping entries (like file handles, etc.).

Describe the relationship between a process and a thread in a multicore system

A process is the entity that creates and manages threads. Therefore, all threads belong to a process, processes do not belong to a thread. The process is controlled by the Process Control Block, and so are the threads - they are also controlled by the Process Control Block. If a process is terminated, its threads cannot survive without it, but a process can survive the termination of one or all of its threads. (The relationship between the two is the same regardless of how many cores are supported for the system.)

What is transfer rate?

A rate that data flows between a drive and a computer

4.What resources are required to create a thread? Why or how is this different than process creation?

A thread needs just a new program counter, register set, and stack. No new memory structures or operating system resources are needed.

What are the advantages of User level threads?

Advantages: -User-level threads does not require modification to operating systems. -Thread switching does not involve the kernel -- no mode switching -Scheduling can be application specific -- choose the best algorithm. -User-level threads can run on any OS -- Only needs a thread library

How many deadlock conditions must be present to cause a deadlock?

All 4

What is mutual exclusion?

Allowing only one process to a dedicated resource

Is this program, as presented, without race condition or do the accesses to 'shared_var' by the two threads need to be protected with a mutex? Justify your answer! Global definitions and code executed before thread: void *shared_var; sem_t sem; sem_init(&sem, 0, 0); Executed by thread 1: shared_var=compute(); sem_post(&sem); Executed by thread 2: sem_wait(&sem); return shared_var

Answer: No mutex is needed since the semaphore guarantees that the assignment to shared_var happens before the use in the return statement. (In fact, this is the pattern exploited by the future_get() implementation in your thread pool!). The use of sem_post() and sem_wait() also ensures that the store by thread 1 will be seen by the subsequent load by thread 2, even if they run on different cores.

What is the analogy to SaaS?

Application, Middleware, Hardware- Analogy: Restaurant. Prepares & serves entire meal, does the dishes, ...

Suppose your operating system has 14 devices, but supports the Banker's Algorithm. this system require a maximum of five devices to complete their execution but they each run for long periods of time with just three devices and request the remaining two only at the very end of the run. Assume that the job stream is endless What are the minimum and maximum number of devices that may be idle as a result of this policy? Under what circumstances would an additional job be started?

At the beginning of the run, two devices are not allocated, but those two can be allocated to any job so it can finish and release its devices so the next waiting job can immediately begin its execution.

Deadlock: What is avoidance?

Avoid deadlock if it is possible

If a process terminates, will its threads also terminate, or will they continue to run? If all of its threads terminate, will the process also terminate, or will it continue to run? Explain your answers.

Because threads are created and controlled by a process, the process can survive the termination of its threads, but threads cannot survive the termination of its controlling process. Processes create, control, and terminate, multiple threads, but each thread is controlled by one process through its Process Control Block. As they are described in this text, there is no Thread Control Block.

What is cloud computing?

Cloud computing is a model for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers, storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction

What are condition variables?

Condition variables are entities used within monitors to block and wait for an event, the operations 'wait' waits for the event to occur and 'signal'. operation is used to generate the event. Basically, the thread invoking 'wait' sleeps until another thread wakes it with 'signal'.

What is the Bell-La Padula model?

Confidentiality Model: - ss: "no read up" - *: "no write down" Information can only flow UP

MAC vs DAC ease of implementation

DAC = easier to implement MAC = harder

MAC VS DAC flexibility

DAC is more flexible, MAC is less

MAC vs DAC how does it restrict?

DAC: the OWNER of a resource restricts access to the resource based on the ID of the users MAC: restricts based on the CLEARANCE of the SUBJECTS

Does safety in the bankers' algorithm eliminate all possible kinds of deadlock?

Deadlock occurs when two or more processes are waiting for one another in some way. Regardless of the causes of these waits, they are in essence "synchronization events" that can be modeled as shared resources.

Explain briefly why implementing critical sections by disabling interrupts will not work on a multiprocessor.

Disabling interrupts will not work on a multiprocessor because disabling interrupts only happens on the CPU it runs. Another thread can run on another CPU and gets into the critical section.

What is DAC?

Discretionary Access Control (DAC) -User-oriented security policy (based on identity of requestor) -Entity has rights to enable another entity to access a resource

What does MAC and DAC stand for?

Discretionary Access Control and Mandatory Access Control

What is disk striping? (RAID 0)

Disk striping is the process of spreading data among multiple drives. (fast) if one disk gets lost a portion of data is lost

What are minimal user requirements?

Each user: -Should be able to r/w/e/d files -may have controlled access to other users files -may control what type of accesses are allowed to their files -should be able to reformat their files -should be able to move data b/w files -should be able to backup/recover files -should be able to access files by name

Suppose there are two processes, A and B, which share semaphores R and S. At the starting time, R = 0, S = 1. A and B are entering the sections of code shown below: Process A: P(R); P(S); Operation A.1; V(S) Operation A.2; V(R); Process B: Operation B.1; V(R); Operation B.2; P(S); Operation B.3; V(S); True or False: Operations A.1 and B.2 cannot execute simultaneously.

False. After B has executed V(R), A can proceed with executing P(R), P(S) and enter operation A.1, and B can simultaneously enter operation B.2. • C. Operations A.1 and B.3 cannot execute simultaneously

Suppose there are two processes, A and B, which share semaphores R and S. At the starting time, R = 0, S = 1. A and B are entering the sections of code shown below: Process A: P(R); P(S); Operation A.1; V(S) Operation A.2; V(R); Process B: Operation B.1; V(R); Operation B.2; P(S); Operation B.3; V(S); True or False: Operations A.2 and B.3 cannot execute simultaneously

False. Operation A.2 is protected by semaphore R while operation B.3 is protected by semaphore S.

Suppose there are two processes, A and B, which share semaphores R and S. At the starting time, R = 0, S = 1. A and B are entering the sections of code shown below: Process A: P(R); P(S); Operation A.1; V(S) Operation A.2; V(R); Process B: Operation B.1; V(R); Operation B.2; P(S); Operation B.3; V(S); True or False: The system may deadlock

False. Process B does not do any "hold and wait", so deadlock is impossible.

What is FCFS (disk)?

Fist come first serve, what ever is in the queue first is found

What is the analogy for Iaas?

Hardware - Grocery store. Provides raw ingredients

Consider the following program segments for two different processes (P1, P2) executing concurrently and where B and A are not shared variables, but x starts at 0 and is a shared variable. If the processes P1 and P2 execute only once at any speed, what are the possible resulting values of x? Explain your answers. P1 for(a = 1; a <=3; a++) x = x + 1; P2 for(b = 1; b <=3; b++) x = x + 1;

If Processor 1 and Processor 2 start at the same time with X=0 then, no matter which one finishes first, the answer will be 6. An alternate scenario would be to reset X to zero before either Processor 1 or Processor 2 started execution. That is, include X = 0 as the first line of both Processor 1 and Processor 2. Then the results will vary depending on the speed of each process. For example, suppose that Processor 1 is faster and finishes before Processor 2 starts up, then the answer would be 3 because X is reset to zero upon starting up Processor 2. You could end up with 4 or 5 as the answer depending on when the second process started executing.

This system has 12 devices. Job 1: Allocated: 5 required: 8 Remaining needed1: 3 Job 2: Allocated: 1 required: 4 Remaining needed2: 3 Job 3: Allocated: 5 required: 7 Remaining needed3: 2 If the system is in an unsafe state, show how it's possible for deadlock to occur.

If any of the jobs actually needs the maximum number of devices, (all of the maximums are more than the 1 device remaining) then a deadlock will result.

What are solid state disks?

Nonvolatile memory used like a hard drive Can be more reliable than HDDs More expensive per MB Maybe have shorter life span Less capacity But much faster Busses can be too slow -> connect directly to PCI for example No moving parts, so no seek time or rotational latency

How does disk mapping work?

In order through that track, then the rest of the tracks in that cylinder, and then through the rest of the cylinders from outermost to innermost

What is mirroring or shadowing RAID 1?

Keeps duplicate of each disk so info isn't lost (slow) better data reliability

5.What's the advantage of including kernel threads as well as processes in an operating system?

Kernel threads allow scheduling on a thread level, and prevent all threads in a process from blocking when a single thread (and therefore the process) blocks. The kernel can also schedule threads on different processors of a multiprocessor.

What is the C-SCAN (circular) (Disk)?

Like the elevator/scan but returns to beginning after reaching the last one (right to left)

What are device drivers?

Lowest level Communicates directly with peripheral devices Responsible for starting I/O operations on a device Processes the completion of an I/O request Considered to be part of the operating system

MAC vs DAC security

MAC is more secure

What is MAC?

Mandatory Access Control (MAC) -Access permissions are defined by a system itself -Based on comparing security labels of system resources (e.g. top security, low security) with security clearances of entities accessing the resources -Cleared entity cannot pass on access rights to another entity

What runs on the cloud?

Many potential applications: Application hosting, backup/storage, scientific computing, content delivery, ...

What are clusters?

Many similar machines, close interconnection (same room?) - Often special, standardized hardware (racks, blades) - Usually owned and used by a single organization

What are file management objectives?

Meet the data management needs of the user Guarantee that the data in the file are valid Optimize performance Provide I/O support for a variety of storage device types Minimize the potential for lost or destroyed data Provide a standardized set of I/O interface routines to user processes Provide I/O support for multiple users in the case of multiple-user systems

What is the analogy for Paas?

Middleware, hardware- Take-out food. Prepares meal, but does not serve it

What are monitors?

Monitors are a programming language construct designed to simplify control of concurrent access. Code related to a shared resource (and the shared resource itself) is placed in a monitor, then the compiler ensures that there is only one thread executing inside the monitor at a time.

Compare and contrast multiprocessing and concurrent processing. Describe the role of process synchronization for both systems.

Multiprocessing, as used in this text, can be several jobs executing at the same time on a single processor or on multiple processors. Concurrent processing, as used in this text, refers to a single job that is executed using several processors to execute sets of processes in parallel. The need for process synchronization is important in both cases but especially critical for concurrent processing where the results of calculations performed at the same time on different processors are used to continue calculations for a single equation.

What are four conditions required for deadlock?

Mutual exclusion, resource holding, no preemption, circular wait.

This system has 12 devices. Job 1: Allocated: 5 required: 8 Remaining needed1: 3 Job 2: Allocated: 1 required: 4 Remaining needed2: 3 Job 3: Allocated: 5 required: 7 Remaining needed3: 2 If the system is in a safe state, list the sequence of requests and releases that will make it possible for all processes to run to completion.

N/A it is unsafe

What are the types of system virtualization?

Native/Bare metal (type 1) -higher performance Hosted (Type 2) -Easier to install -Leverage host's device drivers -VMware

Does lack of safety in the bankers' algorithm guarantee deadlock? Why or why not?

No. An unsafe state is one that can potentially lead to deadlock, not one that will deadlock. For example, there is no accounting for the situation in which a process dies suddenly from causes unrelated to the deadlock, e.g., from signal handling. Sudden death of a process in an unsafe state can lead to a safe state.

What is resource holding?

Not releasing a resource while waiting for another job to release resources

What is the biggest performance cost in context switching?

On a machine with a large # of registers, loading them out of memory is slow. On machine with small set of registers there may be a change in the processors memory management structures

What is the output after executing this program? void fork1 () { int x = 1; if (fork() == 0) { printf("Child has x = %d\n", ++x); } else { printf("Parent has x = %d\n", --x); } }

Parent has x = 0 Child has x = 2

Deadlock: What is prevention?

Prevent occurrence of one condition

What are the two types of virtualization?

Process level & system level

What are the 3 types of cloud?

Public cloud, community cloud, private cloud.

Deadlock: What is recovery?

Resume system normalcy quickly and gracefully

What is RBAC?

Role-Based Access Control (RBAC) Based on roles that users have within system and on rules stating what accesses are allowed to users in given roles

What type of storage are magnetic disks?

Secondary

What is the first sector of the first track called?

Sector 0

What is SSTF(disk)?

Short seek-time first may cause starvation goes to the closest first

What are the three cloud services?

Software as a service (SaaS) Platform as a service (PaaS) Infrastructure as a service (Iaas)

Briefly explain how the above solution may lead to deadlock. Give one possible remedy to the deadlock problem. semaphore fork[5] = 1,1,1,1,1; /* each semaphore is initialized to 1 */ philosopher (int i) /* philosopher i=0,1,2,3,4 executes this code */ { while(1) { think(); wait(chopstick[i]); wait(chopstick[(i+1)%5]); eat(); signal(chopstick[(i+1)%5]); signal(chopstick[i]); } }

Suppose all philosophers execute the first DOWN operation, before any have a chance to execute the second DOWN operation; that is, they all grab one chopstick. Then, deadlock will occur and no philosophers will be able to proceed. This is called a circular wait. Other Solutions: (1) Only allow up to four philosophers to try grabbing their chopsticks. (2) Pick-up the forks only if both are available. Note: this solution may lead to starvation. (3) Asymmetric solution: Odd numbered philosophers grab their left chopstick first, whereas even numbered philosophers grab their right chopstick first.

Many operating systems designed to run only on uniproccessors use disabling of interrupts to create critical sections in the code. Explain briefly how the interrupt disabling prevents multiple threads from entering the critical section.

Suppose two threads can enter a critical section simultaneously on a uniprocessor. Thread A gets into the critical section first. Then the scheduler suspends thread A and run thread B. Thread B gets into the critical section. This is not possible because the scheduler can only be involved either by calling Yield() or a timer interrupt. Thread A cannot call Yield() because it is in the critical section. A timer interrupt is not possible because interrupts are disabled.

What is the central goal of most multiprocessing systems?

The central goal of a typical multiprocessing systems is to serve the processes fairly and accurately, even in failure mode.

Explain what happens if a parent process does not 'wait' for the termination of a child process?

The child process is a zombie process; it will continue to hold resources

What is the scan/ elevator algorithm(disk)?

The disk arm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues. (left to right)

Suppose your operating system has 14 devices, but supports the Banker's Algorithm. this system require a maximum of five devices to complete their execution but they each run for long periods of time with just three devices and request the remaining two only at the very end of the run. Assume that the job stream is endless What is the maximum number of jobs that can be in progress at once? Explain your answer.

The max run is 4 because each job is allocated its 3 maximum devices at the beginning so 12 devices are allocated and 2 remain available which matches the remaining need for any of the 4 running jobs.

Consider a system with 14 dedicated devices of the same type. All jobs currently running on this system require a maximum of five devices to complete their execution but they each run for long periods of time with just three devices and request the remaining two only at the very end of the run. Assume that the job stream is endless and that your operating system's device allocation policy is a very conservative one: No job will be started unless all the required drives have been allocated to it for the entire duration of its run. What is the maximum number of jobs that can be active at once? Explain your answer.

The maximum number of jobs that can be active at once is 2, because each job is allocated its five devices at the beginning of the run and there are enough devices to begin 2 jobs, each with 5 devices. Four devices will remain unallocated.

What is deadlock?

The permanent blocking of a set of processes that either compete for system resources or communicate with each other

2.What hardware/architecture support would you need to make context switching "free"? Explain how this support would be used by the OS.

The processor could store multiple sets of registers in hardware, so that saving and restoring registers is not needed. The processor can also handle saving and restoring registers in hardware, allowing it to happen both more quickly and overlapped with other computation. Finally, the processor can also make it fast to change memory management information (page tables). Only hardware to store multiple sets of registers requires support from the operating system, which can assigning the most frequently running processes to the hardware sets of registers.

What is seek time?

Time to move the disk arm to the desired cylinder. (between disks)

a virtual cylinder where seek time is 4 ms/track, search time is 1.7 ms/sector, and data transfer time is 0.6 ms. Calculate the resulting seek time, search time, data transfer time, and total time read/write head begins at Track 0, Sector 0 T | S | | | | | ---------------------- 0 | 0 | | | | | ---------------------- 1 | 0 | | | | | ---------------------- 1 | 4 | | | | | ---------------------- 1 | 0 | | | | | ---------------------- 3 | 1 | | | | | ---------------------- 2 | 4 | | | | | ---------------------- 3 | 0 | | | | |

Track Sector Seek Time Search Time Data Transfer Time Total Time 0 0 (Starting Place) 1 0 4 ms 0 ms 0.6 ms 4.6 ms 1 4 0 ms 3 * 1.7 ms 0.6 ms 5.7 ms 1 0 0 ms 1.7 ms 0.6 ms 2.3 ms 3 1 8 ms 0 ms (because the head is already at the end of sector 0 & beginning of sector 1) 0.6 ms 8.6 ms 2 4 4 ms 2 * 1.7 ms 0.6 ms 11.4 ms 3 0 4 ms 1.7 ms 0.6 ms 6.3 ms

Suppose there are two processes, A and B, which share semaphores R and S. At the starting time, R = 0, S = 1. A and B are entering the sections of code shown below: Process A: P(R); P(S); Operation A.1; V(S) Operation A.2; V(R); Process B: Operation B.1; V(R); Operation B.2; P(S); Operation B.3; V(S); True or False: Operations A.1 and B.3 cannot execute simultaneously

True. Mutual exclusion between A.1 and B.3 is enforced by the semaphore S. Both A.1 and B.3 are preceded by P(S) and followed by V(S).

Suppose there are two processes, A and B, which share semaphores R and S. At the starting time, R = 0, S = 1. A and B are entering the sections of code shown below: Process A: P(R); P(S); Operation A.1; V(S) Operation A.2; V(R); Process B: Operation B.1; V(R); Operation B.2; P(S); Operation B.3; V(S); True or False: Operation A.1 cannot start until operation B.1 is complete.

True. Process A cannot complete its call to P(R), and therefore cannot start operation A.1, until process B executes V(R). B does not execute V(R) until after it completes operation B.1.

Consider the two pairs of blocks of pseudo code below: -pseudo code can be interrupted and swapped out any line -code assume that each block of pseudo code represents separate processes running concurrently. --------------------- void procB( ) mutexWait(&res2); mutexWait(&res1); useBothRes( ); mutexSignal(&res1); mutexSignal(&res2); void procA( ) mutexWait(&res1); mutexWait(&res2); useBothRes( ); mutexSignal(&res2); mutexSignal(&res1); ---------------------- Which pairs of processes will potentially deadlock? Which pairs of processes should not deadlock?

WILL DEADLOCK: get res 2 [switch>] get res 1 no res 1? [<switch] no res 2? *deadlock* If you run through each separately there will be no deadlock

What is a head crash?

When the disk makes contact with the disk surface (bad)

What is spooling?

a process that accepts and stores multiple user outputs until the device (ex printer) can do the job

What is virtualization?

a technique for hiding the physical characteristics of computing resources from the way in which other systems, applications, or end users interact with those resources. This includes making a single physical resource appear to function as multiple logical resources; or it can include making multiple physical resources appear as a single logical resource

) Suppose that two long running processes, P1 and P2, are running in a system. Neither program performs any system calls that might cause it to block, and there are no other processes in the system. P1 has 2 threads and P2 has 1 thread. a) What percentage of CPU time will P1 get if the threads are kernel threads? b) What percentage of CPU time will P1 get if the threads are user threads?

a) If the threads are kernel threads, they are independently scheduled and each of the three threads will get a share of the CPU. Thus, the 2 threads of P1 will get 2/3 of the CPU time. That is, P1 will get 66% of the CPU. b) If the threads are user threads, the threads of each process map to one kernel thread, so each process will get a share of the CPU. The kernel is unaware that P1 has two threads. Thus, P1 will get 50%of the CPU.

Some hardware provides a TestAndSet instruction that is executed atomically, and that is used to implement mutual exclusion. a) What does the TestAndSet do? b) write code to show how it can be implemented

a) sets a value to a variable and returns the old value atomically b) boolean lock; // Shared, initially false while (TestAndSet(&lock, true)) {} Critical section lock = false

How do you calculate access latency?

average seek time + average latency

Consider a system with 14 dedicated devices of the same type. All jobs currently running on this system require a maximum of five devices to complete their execution but they each run for long periods of time with just three devices and request the remaining two only at the very end of the run. Assume that the job stream is endless and that your operating system's device allocation policy is a very conservative one: No job will be started unless all the required drives have been allocated to it for the entire duration of its run. What are the minimum and maximum number of devices that may be idle as a result of this policy? Under what circumstances would an additional job be started?

b. The minimum number of idle devices is 4. There are always four devices that are not allocated. (Of course all 13 drives could be idle if there were no jobs in the system but this question assumes a continuous job stream.) The maximum number of idle devices is 8 (4 that were not allocated plus 2 each for the two jobs that have not yet accessed their last 2 devices). There would have to be 5 devices available before another job would be allowed to begin.

What is a field?

basic element of data contains a single value fixed or variable length

What are the 3 types of kernel semaphores?

binary semaphores counting semaphores reader-writer semaphores

What is a database?

collection of related data relationships among elements of data are explicit designed for use by a number of different applications consists of one or more types of files

What is a record?

collection of related fields that can be treated as a unit by some application program fixed or variable length

What is a file?

collection of similar records treated as a single entity may be referenced by name access control restrictions usually apply at the file level

What is a File Allocation Table? (FAT)

data structure used to keep track of the portions assigned to a file This is a file system that can support partition sizes up to 2 TB. This file system is very versatile, and allows you to exchange data with OSs other than Windows. Versions include FAT12, FAT16, and FAT32. 4 GB is the maximum file size in a FAT system, and 32 GB is the maximum volume size.

What is a virtual device?

dedicated device made shareable (like a printer)

Deadlock: What is detection?

detect deadlock when it occurs

What is circular wait?

each process waiting for another to voluntarily release so at least one can continue

What is no preemption

if a process holding certain resources is denied a further request, that process must release its original resources and request them again OS may preempt the second process and require it to release its resources

What is the disk bandwith?

the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer

Describe a scenario of context switches where two threads T1 and T2 can both enter a CS guarded by a single mutex semaphore as a result of a lack of atomicity void Wait (Semaphore S) while (S.count >= 0) S.count = S.count - 1 void Signal (Semaphore S) S.count = S.count + 1

if count = 1, T1 calls wait and executes the while loop, and breaks out because it is not neg. Context switch before D1 can decrement. T2 calls Wait executes the whlile loop decrements count and enters the CS. Another context switch, T1 decrements and enters the CS

What is no preemption?

lack of temporary reallocation of resources

What are atomic operations?

operations execute without interruption and without interference (integer operations, counters)

List the 3 most important attributes that an operating system maintains to keep track of information about a thread

program counter (PC) registers stack thread ID can be also a possible answer, for partial marks

How do you resolve a deadlock?

remove one of the conditions

What is positioning/ random access time?

seek time + search time

What is RAID 1+0

striping and copy (high performance and reliability)

What is responsible for using hardware efficiently?

the OS (want to min seek time)

What is file organization and access?

the logical structuring of the records as determined by the way in which they are accessed

What is search time/rotational latency?

time for desired sector to rotate under the disk head

This system has 12 devices. Job 1: Allocated: 5 required: 8 Remaining needed1: 3 Job 2: Allocated: 1 required: 4 Remaining needed2: 3 Job 3: Allocated: 5 required: 7 Remaining needed3: 2 Determine whether each system is in a safe state or an unsafe state.

unsafe (there is only one remaining device and two are minimum to complete a job in order to release resources)


Related study sets

Chapter 3. Life Policy Provisions, Riders and Options

View Set

Chapter 12-Managing Human Resources

View Set

Types of Data, Chapter 1 (Section 1.2)

View Set