Operating Systems Part
Compare "CPU-scheduling" and "Job-scheduling"
"Job-scheduling" provides balanced mix of jobs that it loads into the memory for "CPU-scheduling." The "CPU-scheduling" increases performance according to that criteria.
Compare "race condition" and "critical section"
"Race condition" is a condition that occurs inside a "critical section." A "critical section" is a piece of code that is executed by multiple threads.
Compare "timesharing" and "multiprogramming"
"Timesharing" is the sharing of computer resources among several users at a time. "Multiprogramming" is the allocation of more than one concurrent program on a computer and its resources
Compare "fseek()" and "rewind()"
"fseek()" sets the file position of the stream to the given offset. "rewind()" sets the file position to the beginning of the file of the given stream.
Compare "pointer" and "array"
"pointers" can refer to an individual item or to an "array" of items. An "array" creates both a list of items and a pointer to the first item on the list in one declaration.
Compare a "union" and "struct"
'union' has all elements stored in one place, 'struct' has separate memory locations for each element.
What three things can a process do when receiving a signal?
- Default, Ignore , Catch
What are the two basic types of "sockets?"
- STREAM sockets: Connection oriented, reliable, byte stream communication, non-preserved message boundaries. - DATAGRAM sockets, Connectionless, unreliable, message boundaries perversive, packets normally small.
How do client-server interact with socket based communication?
Client programs have socket interfaces where sockets connect to numbers known as ports.
Compare "system call" and "library call"
Functions in "system calls" are provided by the kernel. Functions in "library calls" are in program libraries
What are resources?
Objects to which processes can be given exclusive rights
OS provides services to users and underlying system
Users - program execution, file manipulation, (I/O) operations, communications System - resource allocation, accounting, protection
Co-operative Multitsking is...
When a process gives one process a break and gives another one control
Pre-emptive multitasking is...
When processes are periodically interrupted by OS to give control to another
Semaphore used to protect critical sections
- 'Down operation', decrements a semaphore or puts process to sleep if 0 - 'Up operation', increments semaphore or wakes up process if sleeping
What is does a cooperative process need?
- A mechanism for communication between them - Synchronization between processes
What are the conditions of a "deadlock"?
- All four conditions must be met simultaneously to cause deadlock 1) Mutual Exclusion 2) Hold and wait 3) No preemption 4) Circular wait
Two goals of an operating system?
- Convenience - Efficiency & fairness
All the base numbers of the constants are...
- Decimal is base 10 - Hex is base 16, and starts with '0x' - Octal is base 8, and starts with '0' - Binary is base 2, can be split in groups of 4
Virtual Machine
A computer system emulator. It comes with every operating system.
What are "zombie" processes?
Child processes that are finished but not waited for.
How do you construct a named pipe?
With a 'mknod' system call: mknod aPipe p - Can be used between unrelated processes - Persist after process has used them
How do you construct an unnamed pipe?
With a 'pipe' system call: int pipe(int fdes[2]) - Can only be used between related processes - Disappeare when process is finished
compare "zombie" and "orphan"
Zombie processes are child process that are finished but are not being waited on. Orphan processes are child process whose parent process has terminated.
What does 'perror' do?
perror takes a string and prints out message according to 'errno'
What are the two main functions of an Operating System?
- To manage access to hardware resources (protection, fairness, efficiency) - To provide high levels of hardware abstraction
What are the bitwise functions defined
- ^ = XOR, 1 or the other, but not both - | = OR, 1 or the other, or both - << or >> = decimal amount shift
What solutions to the 'critical-section' process must be satisfied?
- Mutual exclusion - Progress - Bounded waiting
What can you do to recover from a "deadlock"?
- Preemption, reallocate resources from processes until deadlock is broken - Termination, kill one or more of the processes
Setting up a socket for a server...
1) Create 'socket' 2) Initiate a 'connect' with server 3) Use 'read' and 'write'
Setting up a server for a socket...
1) Create 'socket' (System call) 2) Assign port # with 'bind' (System call) 3) Create a queue for connection requests with 'listen' 4) Server is ready to 'accept' from client process 5) Connection made: server can now 'read' and 'write'
Describe AC^3
A - Asynchronous, operation made to free a process from interruption C - Communication, should be able to pass info C - Concurrency, should have controlled access to shared resources C - Consistency, should ensue data consistancy
What is a process tree?
A hierarchy of Parent and Child processes
What is multitasking?
Allowing for more than one process at a time
What is a cooperative process?
A process that can affect or be affected by other executing proccesses
What is an independent process?
A process that cannot be affected by other executing processes
What is a preemptable resource
A resource which can be taken away w/o causing the computation to fail
What is a non-preemptable resource
A resource which cannot be taken away w/o adverse effects on results (Ex. deadlocks)
How many possible values are there for 'errno'?
About 120 in 'errno.h'
What do 'init' processes do?
Adopt orphan zombie child processes
OS shell is..
Interprets commands and provides an interface for user
How can you distinguish a "library call" from a "system call"?
LIbrary calls usually start their functions with "f" (Ex. fopen() & fclose()) and system calls usually don't.
How are pipes achieved between programs?
Pipes are achieved by connecting the output of one program to the input of another.
What are the three states of a running program?
Running, Blocked, Ready
Compare SIGSTOP and SIGKILL
SIGSTOP stops the process from executing and SIGKILL kills the process.
What is an Operating System?
Software that acts as an intermediary between the hardware and application programs.
System calls are...
The programmer's interface to the operating system.
What is a "deadlock"?
The state of a system where each process in a set is waiting for an event that can only be caused by another process in the set.
What are signals?
They are generated when an event requires attention and are received by processes. (Ex. pressing ctl-z)
What are "sockets?"
They provide an interface to the communication network and can have different domains on a network. Usually used for client-server applications
What primitives does message passing consist of?
send & recieve
What is increment in semaphore?
signal() or up()
What is execvp?
takes argument as array, used when items are unknown beforehand
What is execlp?
takes argument as list, used when items are known beforehand
What is decrement in semaphore?
wait() or down()