Operating Systems II Flashcards
What do you have to do to run powershell commands? What is their file extensions?
- run as admin
- .ps1
Which commands do not carry over from bash?
- chmod
- wc
- < but >»_space; are allowed
- grep is instead called sls
- case is instead called switch
What is the measure-object command?
- allows us to retrieve information of passed in values
- such as count, sum, min and max
What is the sign for variables in PS?
$
What is the correct formation for functions and conditional structures?
- Functions must be defined with “Function” before the name
- round brackets are used for conditionals
How can process be created? What is it called?
- can be created by a user or by another process (parent and child processes)
- spawning is act of creating a new process
What happens in process creating in UNIX?
- first process created at start up is responsible for scheduling (called sched) and has PID = 0
- creates another process (called init) which is origin of all child processes PID=1
What is fork and what is exec?
- two system calls used to create process in a programme
- Fork = creates an exact copy (child) of the current process in a separate memory space
- exec = called by the child, loads a new program in the memory space (replace)
What is a thread?
- unit smaller than a process, can be scheduled and executed
- can have single threaded (common) and multi-threaded processes (maximises eff)
What is context change?
- during switch from process 1 to process 2 the OS stores the current state of p1 and the last state of p2
- time consuming
What is the definition of scheduling?
-trying to find the most efficient assignment of processes to the CPU
What are the 3 types of scheduling?
- high level scheduling HLS = whether to admit process or not
- MLS = temporarily remove or reintroduce a new process
- LLS = decides which ready process must be assigned to CPU
What are the 5 different states?
- Running - process assigned to CPU
- blocked - process is waiting for I/O
- ready - process is waiting to be assigned to CPU, cpu busy
- suspend and resume - suspended process remain in sleep mode until resumed
- processes can be suspended at the blocked, ready and running stage and will enter either blocked suspended or ready suspended
What is pre-emptive scheduling policy?
-remove a process from running state
What are non-pre-emptive scheduling processes
-processes run until they perform an I/O operation (blocked) or simply terminate
What is FCFS?
- Non-pre-emptive
- ready process is dispatched when the running process releases CPU
- run to completion
- average waiting time depends on order in which processes are fed into it
- simple and fast, bad for short and I/O processes
What is shortest job first?
- completes shortest job start to finish
- non-pre-emptive
- calculates shortest estimated run time
- next process is the one in the ready queue with the shortest estimated time
- some longer processes may never be seen (starvation)
What is shortest remaining time?
- pre-emptive
- process with shortest time runs unless a new process comes with a shorter time, in which case that new process is executed
- better for short processes, starvation
What is highest response ratio next?
- non-pre-emptive
- both waiting time and run time considered
- one way to work out priority is; p = (wait time +run time)/run time
- wait time set to 0 for every process and beginning so each one has priority 1
- if wait time increases so does priority
- no starvation, more complicated
What is round-Robbin?
- pre-emptive
- processes are all given equal amount of time in CPU (time quantum)
- time quantum should not be too short
- if process does not finish it is sent to back of queue
- simple with no starvation, frequent context changes
What are MLFQ’s?
- pre emptive that combines many techniques
- different priority level FIFO queues
- enter first priority level, executed for time quantum, sent to second priority queue if not finished, executed for time quantum etc unless another process enters a higher P queue in which case that will be executed until it catches up with first process or it completes
- favours short and new processes, starvation (solved by varying time quantum and priority)
What are concurrent programming applications?
-set of cooperating processes dealing with asynchronous events
What are resources?
- processes can be competing for hardware or logical resources
- there are two types; reusable (not destroyed when being used; hardware) and consumable (temporary data or signals created by a processes and deleted when received by another)
What is serially reusable?
- can only be used by one process at a time
- it is mutually exclusive
What is the critical region?
- eg; we have 2 processes with critical regions. If A enters its region B cannot enter its region and pauses. The CR requires mutual exclusion
- also works vise versa
- data could be lost of both enter region at same time
How does OS deal with mutual exclusion?
- allows processes to exit without fear of data loss
- efficient, equitable handling of shared resources
What is a deadlock?
- processes created by the need for mutual exclusion has the potential for deadlocks
- processes waiting for events that will never occur
- can create deadlock circle; process P1 is using printer and needs access to file F, P2 already has mutual access to file F and is waiting on printer
What is the hardware approach to achieving mutual exclusion?
- CPU could provide special instruction called test-and-set
- checks he value of a flag then sets it to 1, in one operation
- no delays between testing values and setting them
- does not waste time in busy waiting
What are semaphores?
-special type of variable. Two operations can be performed on them;
Wait - controls entry into critical region
Signal - controls exit from region
-no wasting time as processes checked before being executed rather than executing slightly then being blocked
-wait and signal cannot be interrupted
-LLS can block these processes instead of waiting time n busy-waiting
-there can be binary and counting (>=0) semaphores
What is race condition?
-occurs when competing processes attempt to perform operations at the same time - without mutual exclusion
What are the 4 conditions for a deadlock to occur?
- mutual exclusion
- resource handling - process holding some resources waiting for others
- no pre-emotion - resources cannot be forcibly removed from a a process
- circular wait
What are the four strategies for deadline with deadlocks?
- deadlock prevention - one of the four conditions for the deadlock is denied
- deadlock avoidance - the four conditions still prevail, but when a deadlock would arise from a resource allocation, it is not made
- deadlock detection - deadlocks can happen and then broken by the same means
How effective is deadlock prevention?
- mutual exclusion cannot be disallowed
- resource holding cannot relinquish resources and no pre-emption has the same problem
- circular wait can be prevented if resources are organised into an order. Inefficient and difficult to apply
How efficient is deadlock avoidance?
- process requests are checked dynamically to decide whether to allocate a resource or not
- current resource - allocation state is evaluated, considering the max number of resources required by each process
- if all necessary resources can be assigned (in any order), the state is safe, otherwise it is unsafe
What is the bankers algorithm?
- helps avoid deadlocks
- requirements = ma number of reassures, number of allocated resources, number of resources available
- resources may be allocated to a process if the resource requested <= amount available. Otherwise wait until resources available
- state = safe if it is possible for all processes to finish their execution, state=unsafe otherwise
How effective is deadlock detection?
- ostrich algorithm = stick head in sand and pretend there is no problem
- Usual principle is to detect a circular wait situation by using resource allocation graphs
- breaking a deadlock implies that processes be aborted, or resources pre-emptied from processes (loss of work)
What are the four main characteristics of IO devices
- Data rate
- Unit of transfer
- Operations
- error conditions
How do IO devices communicate with one another?
- through the bus system
- interrupts used for asynchronous communication with the CPU and the device control
What is the structure of an IO system
-split into hardware and software
software; Application program IO control system IOCS device driver…..
Hardware; …Device controller device
What is the IOCS
- Part of the OS that deals with IO system calls
- IO requests are validated and processed to be handled at the next stage
- IOCS is also responsible for management of IO interrupts
What is a device driver?
- software modules responsible for communication with, and control of, IO devices
- convert user requests into actual instructions for the specific device
- considered part of OS and closely integrated with IOCS
What is the device controller?
- hardware modules that interface IO devices to the bus system
- Device controllers are specifically designed for a computer system
- devices are usually designed, instead, to work with different computer systems
What are block devices
- communicate with the computer system through groups of characters (blocks of data) at a time
- difficult to deal with but faster transfer rate
- DVD’s and CD’s
What are character devices
- communicate by transferring one character at a time
- easier to deal with but slower transfer
- mouse/keyboard
How are devices in Linux seen?
- stored as special files under directory /dev
- as files they can be read or written (not executed), and have permission attributes
What are virtual devices?
- simulate devices which are not physically present or available
- from user POV they look like normal devices so they respond to normal system calls
- in Linux /dev/null
What is data buffering?
- data transfer takes a lot longer than data processing
- can introduce a buffer which allows transferring and processing to occur simultaneously
- information goes into temp buffer first not memory, new info then starts to be fetched and at the same time the info in the buffer goes into working memory
- can add multiple buffers to allow for even more simultaneous processing
What type of files do UNIX and windows have?
Both;
-regular files = programs, text, data etc
-directories = files containing references to other files
Unix;
-character/block special files = not true files, but directory entries that refer to devices
-pipes = temp files for inter-process communication
What is volume?
- refers to actual part of secondary storage used for data
- one physical disk can contain more volumes, formatted with different file systems for different OS’s
- current techniques use dynamic allocation where space is allocated in units of fixed size (allocation units)
- an allocation unit has size of disk physical sector in uNIX or is multiple of them in windows (clusterS)
Difference between chained and listed clusters?
- chained = each cluster points to next one, contain pointer as well as data which takes up more space. Must go through entries chain in order even if you wish to find cluster which is at end of chain
- cluster list = where the file contains a list of all the clusters making up the cluster itself
What is FAT?
- File location table is an array of 16 bit values where each entry is associated to one single cluster (except first 2)
- the value of each entry is a pointer to the next one
- held in memory when the disk is used, access is much faster than basic chained cluster
How does cluster size affect performance?
- cluster is the min size allocated for a file, even if not all used
- smaller the cluster the smaller the chance to waste space, but also bigger FAT table and disk accessed more frequently
- bigger the cluster the smaller the FAT table and number of accesses but also bigger waste of disk space
How do we calculate max disk space based on cluster size?
- since max number of entries in FAT table is 2^16 this then sets max disk space that can be accessed
- eg; if cluster size = 1024
- 1024 * 2^16 = 67108864 (64MB)
What is NTFS?
- New technology file system overcomes limitations of FAT; such as max storage space and security features
- uses Master file table (MFT) to manage the file allocation for the volume
- consists of 1Kb records, each record with attributes relative to one file
- data attribute of an MFT entry can contain the whole file, if its smaller than 700 bytes, or a list of pointers to its relative clusters
Difference between LCN and VCN?
- Each entry in a table contains these
- LCN = logical cluster number with length of contiguous group of physical clusters
- virtual cluster number = indicates the sequential number of clusters within the file
What is an iNode?
- used in UNIX and there is one for each file
- contains; owner and group ID, file type, perms, last access and modified, size, number of links and pointers to disk locations
Structure of an iNode?
- each iNode contains 13 or more pointers
- 10 are used to point directly to data blocks
- 3 are used to point to index blocks
- 3 index blocks can contain new lists of pointers to data blocks or other index blocks