Operating Systems

- resources a processes needs, and a thread needs

Processes

  • have multiple threads
  • Threads actually only run one at a time
  • Threads in the same process have access to the same memory

mutex

  • https://stackoverflow.com/questions/7335950/semaphore-vs-monitors-whats-the-difference
  • is 0 or 1, 1 if the data is locked by another process
  • semaphore is similar but can be greater than 1
    • like only 5 threads can access this things, so if there are 5 accessing it then you have to wait for one to free up
  • monitor is a synchronization construct that allows threads to have both mutual exclusion and the ability to wait (block) for a certain condition to become true.
    • monitor consists of a mutex (lock) object and condition variables.
    • monitor is a binary semaphore

deadlock

  • happens when two processes are waiting for a resource to become available but the resources are dependent on each other so nothing will happen.
  • random priority can help with livelock
    • livelock is when they are trying to fix it but that is causing problems

Context Switching

  • switching of the CPU from one process or thread to another.
  • needed for multitasking
  • no code is being executed so its overhead
  • switching threads is faster because you dont have to flush the virtual memory TBL

Scheduling

  • CPU scheduling is a process which allows one process to use the CPU while the execution of another process is on hold(in waiting state) due to unavailability of any resource like I/O etc, thereby making full use of CPU. The aim of CPU scheduling is to make the system efficient, fast and fair.
  • switches after a clock interrupt, an I/O interrupt, an operating system call or another form of signal