Operating Systems Flashcards
What is an os?
- Particular system software that deals directly with hardware
- facilitates dev and use of programs in a common environment without worrying about the ugly HW part
What is multiprogramming?
-multiple programs run simultaneously by making use of CPU idle time
What is spooling?
- Data is sent to and stored in memory until program or computer requests it for extraction
- eg; in printer spooling, the docs that are sent to the printer are first stored in memory (printer spooler). Once printer is ready, it fetches the data from the spool and prints it
What is OS made of?
- process management
- memory management
- I/O control
- file management
What is a process?
- Execution of a program
- one program can have multiple processes
Where does the OS store processes?
- in the Process control block (pcb)
- each process is assigned a unique numeric ID (process ID)
What are the 4 types of interrupt?
- I/O = generated by device controller
- Timer = generated by internal clock
- Hardware = generated by hardware faults
- program = generated by program errors (division by 0)
What is DMA?
- direct memory access is the transfer between memory and I/O without passing through processor
- processor initialises transfer but is then suspended
- faster data transfer
- processor is noted by interrupt when transfer is completed
What are the 3 types of computer users?
- Programmer
- Operational
- End user
What are the four types of interfaces?
- System call
- command language
- Job control language (JCL)
- GUI
What are system calls?
- like functions
- difference is they do not belong and exist inside an application and are instead part of OS
How are system calls defined in Linux?
- defined at C functions
- one to one relationship
- eg; open, close and read files
How are system calls defined in windows?
- win 32 API
- calls are decoupled from system calls
What are command languages?
- designed to interact with OS via terminal
- used by operational users
What is the difference between UNIX and MS-DOS command languages?
- both use ‘command options arguments’ syntax
- in unix commands can be combined in shell script files
- windows uses batch files
- MS-DOS is a single user language therefore no commands for login, password, file perms etc
What is JCL?
- job control language is designed for control of batch jobs on large computer systems (mainframes)
- job is started by user and then proceeds with little or no intervention
- many things in common with shell scripts but designed for batch use
- pre-defined input without further interactions
What acronym can be used to describe basic features of GUI’s?
WIMP
Windows, icons, menus, pointers
What is the GUI model based off?
- X window system
- principle was transmission between display and computer using character-based messages
- based on client-server model
- client = app requiring GUI
- server = program providing those functionalities for specific hardware
How does the programmer view the GUI?
- provide many properties and tools at expense of more complex code
- use event-driven programming, where program must respond to user actions at every instant
How does the user view the GUI?
- Increased user-friendliness
- standardisation
Features of UNIX command interface?
- user commands
- very short
- type sensitive
- script files used to automate repetitive tasks (executed by typing sh then file name, each line is an instruction)
What is redirection?
- sending output to file or another device
- > overrides current content in file
- > > appends new file to existing one
- < takes input for program from existing file instead of keyboard
- <> is carried out by shell and can be used with any program
What are pipes?
- provide possibility to redirect output or input to selected files or devices
- connect output of one program to input of another
- removes need for temp files eg; ‘who | sort’
- possible to create pipeline where several programs simultaneously process same I/O stream
1) what is process loading?
2) what is swapping?
1) transfer of program to be executed from disk to memory
2) swap of two processes, one in memory and the other on the disk
How is swapping performed?
- processes state and data must be preserved
- special disk space used
- swapping very slow compared to memory speed
- suitable things to be swapped are processes awaiting I/O
What is fixed disk portioning?
- partitions have different sizes with some larger than others to contain bigger processes
- one part of the disk is dedicated to the OS, the rest to different processes
- OS must prevent different processes from accessing addresses outside their own partitions.
- process could be too big for largest memory partition
What is internal fragmentation?
-total amount of unused space between each partition
What is external fragmentation? What causes it?
- adjacent memory spaces, each one the size of a process
- memory filled until almost full
- when problem terminates, it leaves a hole too small or big for another process
What policies are used when deciding where memory is allocated?
Best, worst and first fit
Best = most suitable
Worst = biggest
How does the operating system keep record of available memory space?
- uses a list with each element of the list containing the position size and pointer to next element
- first fit policy will chose first element, best and worst fit must scale the whole list
- this means best fit is efficient but slow
What is variable partition memory?
- moves processes via process of compaction in order to make room for new processes (gets rid of external fragmentation)
- eg; process is done and leaves a hole, processes above is moved down to fill hole leaving room for new process above it
- compaction could be done as soon as process terminates, when a new process cannot load due to fragmentation, at fixed time intervals or when the user decides
- requires relocation of a very large number of processes which means it is in-efficient and not used often
What is paging?
- processes can be divided into pages which are then assigned page frames (sections of memory where pages are stored) of the same size in memory
- pages can be split and separated in memory to make max use of available space
How is the logical address calculated in paging?
-page number and displacement (keeps track of location of processes pages)
How does physical addressing work with paging?
- page number needs to be mapped into a page frame, while the displacement remains fixed
- displacement is taken from logical address
- page frame value is calculated from page number (also taken from LA)
- page frame + displacement
What is a page frame?
-maps the process page numbers to the relative page frames in memory
What are segments?
- divisions of variable size
- eg; a process may have segments a1,a2,a3 each of different size; these are then stored in best position in memory for that size segment
How is logical addressing done in segmentation? What is a segment reference?
- segment reference + displacement
- segment reference used to check on a segmentation table, the base address and the max length of the segment
- table = ref number, length, base address
How is physical addressing done with segmentation?
- one value comprised of displacement + base address
- base address is found by using logical address’ ref number to point to it in the segmentation table
What happens to processes not stored in real memory?
- remain in secondary storage (swap space)
- large amounts of virtual memory becomes available
- processes can be stored in virtual memory and then switched to real
What happens when a new process starts?
-first page of its code/data loaded into memory
-if program execution refers to address outside of current page (page fault) an interrupt is generated, causing the new page to be loaded
(Page Demanding)
-The processes pages loaded in real memory forms the resident set of the process
What is a page table register?
-loaded during context change with the position of the respective page table
What else is stored in a page table?
- Present P bit - indicates the relative virtual page is loaded in real memory (otherwise page fault occurs)
- Modified M bit - indicates the page has been modified while in memory
What does the size of VM depend on?
CPU
What is the problem with page tables?
- can be so big that it must be held outside real memory
- loading a new page can therefore be a long operation, compared to short execution time of program instruction
What is locality of reference?
- programs are structured in a way that during a certain time interval, they use memory addresses that are relatively close to one another
- During this, the process will require no more than a small set of pages
- proportion of process generating a page fault is millions to one
What is the working set?
- number of pages needed by a process during a certain time interval
- ideal would be working set = resident set
What is thrashing?
-if too many processes in memory, the CPU spends most of the time page swapping instead of processing instructions
What is the least recently used algorithm? LRU
- replace page frame which has not been used for longest time
- time stamp is kept for every page frame, updated evert time the latter is referenced
- recording this information for all the page frames and sorting them to get the oldest one i not very practical
What is the not recently used algorithm?
- select any of the page frames which were not used in the last (fixed) period
- A flag is associated to every frame, which is set to 1 whenever the page is used
- OS periodically resets all the flags
What is the FIFO algorithm?
- replace the oldest page frame, chosen from head of queue
- simpler then previous solutions as it does not consider that page may have been recently used
- may remove old frames that are frequently used
What is the clock algorithm?
- circular list with a used bit for every entry, indicating that the page frame was recently referenced
- list is scanned until a frame with used bit = 0 (not used since last visit) is found
- during scanner all encountered bits are set to 0
What are the benefits of segmentation?
- dynamic memory use = segments with growing data structures can get more space
- segments can reflect the logical structure of a process
What are the advantages of paging?
-facilitate complex optimisation techniques
What is a paged-segmented system?
-the programmer works with segments which are then divided (at physical level) into pages
What does a VM address consist of?
- segment number - indexes an entry of the segment table, pointing to a page table for that segment
- a page number - which indexes the page frame in the page table
- displacement - to obtain real memory address
What do the following commands mean?
Pwd, ls, chmod, echo, who, wc, cp, mv, rm
- pwd = prints working directory
- ls = lists directory contents of files and directories
- chmod = used to change perms of files or directories
- echo = used to print information
- who = tells what user are currently logged on
- we = word count of specified item (lines, words and characters)
- cp = copy
- mv = move one file to another (rename)
- rm = remove
What is re-direction?
- > place execution of command into a file (eg; ls > filelist.txt)
- < give information to a command (eg; wc < filelist.txt)
- pipes are also used
What does the cat command do?
- reads data from files and outputs their contents
- simplest way to display the contents of a file at the command line
Difference between single, double and back quotes
-single prints exactly whats in the quotes
-double prints message and variables so “$variable” would print the variable
`` allows commands to be executed
What do \ $# mean?
- \ is a quoting mechanism for single characters
- tells us the number of arguments script is receiving. Can be used in if statements
What do sort, grep and find do?
- sorts things in order
- grep allows the displaying of specific contents in a file (eg; “cat text.txt|grep t”) will display all lines in a given file that have a t in
- find is used to find files in a directory
What do “let” and “expr” mean?
- let command assigns integers to a variable (eg; let x =5)
- expr evaluates expression and outputs corresponding value