211 - Operating Systems Flashcards
What are the functions of a operating system?
- It is an interface between User and Hardware
- Allocates resources to each user to ensure everyone has a fair share
- Managed the memory and security etc
What is the purpose of an OS
- Convenience
- Efficiency
Processes have 1 or more thread….
Small sequences of instructions managed independently by schedular
Benefit of threads
Fast and efficient
What is concurrency?
The act of managing and running multiple computations at the same time
What happens if a thread goes first and another one goes last?
It should have the same outcome
An interface in Java and how to implement it
Runnable and must have “public void run() as it’s method signature to implement it
What are the 3 central concepts in concurrent programming?
- Processor (ingredients)
- Program (recipe)
- Process (food you make)
Which is correct?
A program can have multiple processes
Or
A process can have multiple programs
A program can have multiple processes such as clicking on google chrome 10 times and getting 10 different windows
What is context switching?
Swapping from one process to the other quickly
Which is correct?
Processes are always parallel but not always concurrent
Or
Processes are always concurrent but not always parallel
Processes are always concurrent but not always parallel
What is parallelism?
The act of running multiple computations simultaneously
Weakness of a schedular
It is always adversarial so you expect it to do the worst possible thing
Benefits of multiprocessor systems
- Increased throughput
- Economy of scale
- Increased reliability
When is concurrency safe to do?
When not sharing data and when handling read only data
What is Moore’s law and what’s wrong with it today?
It no longer applies because the transistors get so small that electrons are able to jump over each other due to the lack of space which causes data to be entered in wrong.
Also generates a lot of heat which can cause the hardware to overheat and it’s difficult and expensive to ensure systems don’t overheat
What is Amdahl’s law?
Speed up is limited by the serial part of the program
What is synchronisation?
A mechanism to ensure multiple concurrent processes or threads do not simultaneously execute some particular program segment
What is competition?
Competing for a variable that processes want to reach simultaneously
What is the difference between deterministic and indeterminate?
Deterministic is same output each time and indeterminate is different output each time
What does cooperation do?
It manages the offset or time to ensure threads travel across system resources correctly
What is a critical section?
It is a code section that access a shared resource
What is mutual exclusion?
Only one thread can run within the critical section at any given time
What is a race condition?
An error that occurrs due to multiple processes ‘racing’ in an uncontrolled manner through a section of non-atomic code
What is a semaphore?
It’s either a closed or open condition. When closed, there is no entry, when open there is entry like red and green traffic lights
What operations does a semaphore support?
Wait() and signal()
What does a schedular do?
It maintains the queue or processes.
What are zombie processes?
Threads that are stuck in memory waiting forever to be run. So we must use (public synchronised void) to ensure it doesn’t happen
What do you have to consider when using Notify() and NotifyAll()?
If you do NotifyAll() you must use while loops as while loops check the condition over and over and for Notify() you can use the if statement as it checks the condition only once.
How do you turn a semaphore into a lock?
They are a common type of exclusion lock, by giving it a binary value, it acts like a lock.
What is polymorphism?
An instance of a class which inherits from (extends) another can also be treated like an instance of that class