Operating Systems
1. Describe inheritance, multithreading, watchdog timer, etc.
a. Inheritance: Inheritance allows us to define a class in terms of another class,
which makes it easier to create and maintain an application. Inheritance
allows to reuse the code functionally and allows fast implementation time.
b. Multithreading: Multithreading is the ability of a program to manage its use
by more than one user at a time and to even manage multiple requests by the
same user without having to have multiple copies of the programming
running in the computer.
c. Watchdog timer: WDT is a piece of hardware that can be used to
automatically detect software anomalies and reset the processor if any occur.
2. What is virtual memory and caches(Also read upon Cache coherency)
a. Physical memory is scarce in machines, so virtual memory is an optimization
to expand that
b. Memory stored in pages in hard disk and by using caches
3. What are priority inversion, reentrancy, spinlocks
a. Priority Inversion: lower priority task running with semaphore, higher
priority is waiting for semaphore. Medium priority task interrupts, runs, and
then high priority can run
i. Solution is to bump priority of low priority to highest priority and
then it can’t be preempted by medium (It’s called priority inheritance)
b. Reentrancy: function is reentrant when during its execution if it gets
interrupted, it can return and resume function without any change
i. Can’t use global/static data
c. Spinlock: a task is waiting for a certain resource that is locked and is
continually checking if it opened up, using most of the CPU resources
i. Good rule of thumb - avoid them in user code
4. What is atomic programming/non-locking operation?
a. Atomic operations are operations that are guaranteed to keep their values
safe
Atomicity
In computer programming, an operation done by a computer is
considered atomic if it is guaranteed to be isolated from other
operations that may be happening at the same time. Put another
way, atomic operations are indivisible.
5. What is concurrency, parallelism and multithreading?
a. Concurrency is essentially applicable when we talk about minimum two tasks
or more. When an application is capable of executing two tasks virtually at
same time, we call it concurrent application. Though here tasks run looks like
simultaneously, but essentially they MAY not. They take advantage of CPU
time-slicing feature of operating system where each task run part of its task
and then go to waiting state. When first task is in waiting state, CPU is
assigned to second task to complete it’s part of task. Operating system based
on priority of tasks, thus, assigns CPU and other computing resources e.g.
memory; turn by turn to all tasks and give them chance to complete. To end
user, it seems that all tasks are running in parallel. This is called concurrency.