Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Define by accinent


    Operating System – A virtual machine that hides the complexity and limitations
        of hardware from application programmers.
    Job- a unit of processing.
    Batch system - Collects multiple jobs before execution.
    Timesharing - Multiple terminals per machine.

      Thread – A sequential execution stream, the smallest CPU scheduling unit.
       Offers concurrency.
      Address space – All memory addresses that an application can touch. Offers
       protection among processes.
      Process – An address space + at least one thread of execution.
      Context switch – Save prog. counter, register values, and execution stacks.
      Uniprogramming – Running one process at a time.
      Multiprogramming – Running multiple processes on a machine.
      Multithreading – Having multiple threads per address space.
      Multiprocessing - Ability to use multiple processors on the same machine.
      Multitasking – A single user can run multiple processes.

      Master boot record- stored in the first sector (512 byte) of the boot device (e.g.
       hard drive). The MBR will describe the physical layout of the disk.
      BIOS- Basic Input/Output System, info on how to access storage devices.
      POST- Power-On Self Test, checks memory and devices for their presence and
       correct operations.
      LILO- a more sophisticated, OS specific loader loaded by the BIOS.
      System call- allow processes running at the user mode to access the kernel
       functions that run under the kernel mode.
      User mode- An application can only access its own address space.
      Kernel mode- Anything goes.

      Starvation- One process never runs because higher priority jobs keep coming in.

      Atomic operation- an operation that takes one unit of time, and cannot be
       interrupted by a context switch.
      Race condition- occur when threads share data, and their results depend on the
       timing of their executions.

      Mutual exclusion- only one process runs at a time.
      Critical section- a piece of code that only one thread can execute at a time.

      Busy waiting- a thread could be waiting until signaled to continue by another
       thread or an I/O device.

      Semaphore- generalized lock, positive integer values.
          o P(): atomic operation that waits for semaphore to become positive, then
            decrement it by 1.
          o V(): atomic operation that increments semaphore by 1 and wakes up a
            waiting thread at P(), if any.

      Safety- lock before critical section, free the lock after critical section. Enforce
       mutual exclusion.
      Liveness- the program can progress toward completion.
      Fairness- every thread will eventually get executed.

Short answers:
    Four phases of OS history and their design goals
          o Phase 1:
                Expensive hardware, cheap human labor. Use mainframes.
                Efficient use of the hardware, i.e. Batch system (collects multiple
                    jobs before execution) and Multiprogramming (I/O bound jobs and
                    CPU bound b\jobs can run concurrently)
          o Phase 2:
                Cheap hardware, expensive human labor. Use terminals.
                Efficient use of human resources, i.e. Timesharing systems
                    (multiple terminals per machine).
          o Phase 3:
                Very cheap hardware, very expensive human labor. Use PCs.
                Allow users to perform many tasks at the same time, i.e.
                    Multitasking (multiple programs on the same machine at the same
                    time) and Multiprocessing (ability to use multiple processors on
                    the same machine).
          o Phase 4:
                Distributed systems. Use networking.
                Ease of resource sharing.

      Benefits of concurrency- Ability to run multiple applications at the same time.
       Better average response time. Better performance, one application for the
       processor, and one for the disk drive. Completion time is shorter when running
       both concurrently than consecutively.
      Drawbacks of concurrency- Applications need to be protected. Additional
       coordination and needed. Overhead is need for a context switch. Performance
       degradation when running too many applications.
      Program vs. process – A program is a collection of statements, while a process is
       a running instance of a program.
      Dispatching loop
           o Run thread.
           o Save states.
           o Choose a new thread to run.
           o Load states from a different thread
      Thread state diagram
       o Running- has the CPU.
       o Blocked- waiting for I/O or another thread.
       o Ready to run- on the ready list waiting for the CPU.

   Booting sequence
       o Load fixed address in ROM (Read Only Memory).
       o Load BIOS.
       o Perform POST.
       o Loads MBR from the boot device.
       o Loads an OS loader.
       o Loads the kernel image.
       o Sets the kernel mode.
       o Jumps to the OS entry point.
   System call sequence
       o Trap.
       o Set kernel mode.
       o Branch table.
       o Trusted code.
   Process creation- use the fork() function.

   Preemptive scheduling- a process can be forced to leave it’s running state and
    replaced by another.
   Nonpreemptive scheduling- a process runs on a CPU until it is blocked or
   FIFO- First In First Out.
        o + Simple
        o – Short jobs could get stuck
        o Best- shortest -> longest.
        o Worst- longest -> shortest.
   RR- Round Robin.
        o + Shorter response time.
        o + Fair.
        o – not all jobs are preemptive.
        o Best- shortest -> longest.
        o Worst- all jobs same length.
   SJF- Shortest Job First.
   SRTF- Shortest Remaining Time First, a preemptive version of SJF. Will
    perform a context switch if a shorter job arrives.
   Multilevel feedback queues (AKA priority scheduling)- a priority queue for each
    level, then implement a RR execution, after a process runs, drop in priority, if
    process is blocked for I/O then bump up in priority.
        o CPU bound jobs drop in priority too fast.
        o I/O bound jobs stay on top.
   Lottery Scheduling- each process owns some tickets and is then called by the
    processor at random.
      Independent threads
          o No states shared with other threads.
          o Deterministic (output depends on input).
          o Reproducible.
          o Scheduling order doesn’t matter.
      Cooperating threads
          o Shared states.
          o Nondeterministic.
          o Nonreproducible, ex: 2 threads sharing the same display.
      Decision tree- trace the execution options of 2 threads.

      Code verification

      Ways to implement locks
         o High-level atomic operations- Locks, semaphores, monitors, send and
         o Low-level atomic operations- Load/store, interrupt disables, test_and_set.

      Semaphores vs. integers-
          o No negative values
          o Only operations are P() and V(), cannot modify except at initialization.
          o Operations are atomic, two P() calls cannot decrement the value below
          o A sleeping thread at P() cannot miss a wakeup from V()
      Two uses of semaphores
          o Mutual exclusion- initial value of 1, P() before critical section, V() after.
          o Scheduling- initial value of 0, use V(s2) to wake up a thread 2 and P(s1) to
             wait till that thread is done. Thread 2 will start with P(s2) to wait for it’s
             wakeup, and finish with V(s1) to wake up thread 1 after it’s done.
      Code verification (producer/consumer)
          o Consumer must wait if buffers are empty (scheduling).
          o Producer must wait if buffers are full (scheduling).
          o Only one thread can manipulate the buffer at a time (mutual exclution).

      Code verification

Project 1:
    Jiffie- 1/100th of a second
    Simple C program using fork() etc

     <stdio.h>
     <stdlib.h>
     <sys/time.h>
     <time.h>
      <string.h>
      <unistd.h>

#include for fork program:
     <stdlib.h>
     <unistd.h>
     <stdio.h>

int p = fork();
        // Child

To top