github twitter email rss
Operating Systems
0001 Jun 1
6 minutes read

Operating Systems

NEXT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

OS:TEP: chapters 5-24, Homeworks
MOS: Homework chapter 1, page 81(112)
hw1 hw2
lecture 6-8, videos

Where operating system fits in

OS functions

  • OS easy to use abstraction over hard to use hardware
  • resource management
    • multiplexing (sharing) resources in time and in space.
  • virtualization
    • takes a physical resource and transforms it into a more general, powerful, and easy-to-use virtual form of itself
  • exports a few hundred system calls
  • provides a standard library
  • Concurrency
  • Persistence

Abstraction is the key to managing complexity.
In theory, theory and practice are the same; in practice, they are not.

Computer parts

  • CPU
    • Registers
      • program counter
      • stack pointer
      • PSW (Program Status Word)
    • Pipeline
      • fetch, decode, and execute units
    • Mode
      • kernel
      • user
    • TRAPS
    • system-call
    • multithreading
      • not offer true parallelism
      • thread-switching time is reduced to the order of a nanosecond
    • multicore



Moore’s law states that the number of transistors on a chip doubles every 18 months

  • Memory
    • Registers: typically 32 × 32 bits on a 32-bit CPU and 64 × 64 bits on a 64-bit CPU
    • Cache (L1, L2 …)
      • cache lines: 64 bytes, with addresses 0 to 63 in cache line 0, 64 to 127 in cache line 1, and so on
      • cache hit, cache miss
    • RAM
      • Virtual memory
    • HDD, SSD


  • I/O devices
    • device driver + controller(registers) + device
  • Bus
    cache, local, memory, PCI, USB, IDE, SCSI, ISA, IEEE 1394

Driver-device communication

  • busy waiting
  • interrupt
  • DMA (Direct Memory Access)


OS Kinds

  • Mainframe (OS/390)
    • batch system
    • transaction processing
    • timesharing
  • Server OS
  • Multiprocessor OS
  • Personal computer OS
  • Mobile OS
  • Embedded OS
  • Sensor node OS
  • Real-time OS
    • hard real-time (industrial, military)
    • soft real-time (multimedia)
  • Smart card OS

OS Concepts

  • Process
    • Address space
      • Text (program code)
      • Data (variables)
      • Stack

Process memory

  • Thread
  • process table
  • Interprocess communication
  • Process system calls
  • Signals
  • User
    • UID
    • GID
  • Virtual memory
  • Physical memory
  • File system
  • File
    • file descriptor
  • Special file
    • block special file
    • character special file
  • Directory
  • Path
  • Mounted FS
  • Special file
    block special file
    character special file
  • Pipe
  • RWX bits
    read-write-execute bits for the owner, group, and others
  • Shell

System calls (POSIX)

System call

// Process management 
  pid = fork( )                           // Create a child process identical to the parent
  pid = waitpid(pid, &statloc, options)   // Wait for a child to terminate
  s = execve(name, argv, environp)        // Replace a process' core image
  exit(status)                            // Terminate process execution and return status
// File management
  fd = open(file, how, ...)               // Open a file for reading, writing, or both
  s = close(fd)                           // Close an open file
  n = read(fd, buffer, nbytes)            // Read data from a file into a buffer
  n = write(fd, buffer, nbytes)           // Write data from a buffer into a file
  position = lseek(fd, offset, whence)    // Move the file pointer
  s = stat(name, &but)                    // Get a file's status information
// Directory and file system management
  s = mkdir(name, mode)                   // Create a new directory
  s = rmdir(name)                         // Remove an empty directory
  s = link(name1 , name2)                 // Create a new entry, name2, pointing to name1
  s = unlink(name)                        // Remove a directory entry
  s = mount(special, name, flag)          // Mount a file system
  s = umount(special)                     // Unmount a file system
// Misc
  s = chdir(dirname)                      // Change the working directory
  s = chmod(name, mode)                   // Change a file's protection bits
  s = kill(pid, signal)                   // Send a signal to a process
// Win32 API
  fork CreateProcess                      // Create a new process
  waitpid WaitForSingleObject             // Can wait for a process to exit
  execve (none)                           // CreateProcess = fork + execve
  exit 	ExitProcess                       // Terminate execution
  open 	CreateFile                        // Create a file or open an existing file
  close CloseHandle                       // Close a file
  read 	ReadFile                          // Read data from a file
  write WriteFile                         // Write data to a file
  Iseek SetFilePointer                    // Move the file pointer
  stat 	GetFileAttributesEx               // Get various file attributes
  mkdir CreateDi rectory                  // Create a new directory
  rmdir Remove Directory                  // Remove an empty directory
  link  (none)                            // Win32 does not support links
  unlink DeleteFile                       // Destroy an existing file
  mount (none)                            // Win32 does not support mount
  umount (none)                           // Win32 does not support mount
  chdir SetCurrentDirectory               // Change the current working directory
  chmod (none)                            // Win32 does not support security (although NT does)
  kill (none)                             // Win32 does not support signals
  time 	GetlocaiTime                      // Get the current time

OS Structure

  • monolithic systems
    • As single program in kernel mode
    • main procedure
    • service procedures
    • utility procedures

Monolithic system

  • layered systems
    • choice where to draw the kernel-user boundary.
  • microkernels
    • Idea is achieve high reliability by splitting the operating system up into small, well-defined modules, only one of which—the microkernel—runs in kernel mode and the rest run as relatively power- less ordinary user processes.
  • client-server systems
  • virtual machines
    • type 1 hypervisor
    • type 2 hypervisor


A type 2 makes uses of a host operating system and its file system to create processes, store files, and so on. A type 1 hypervisor has no underlying support and must perform all these functions itself.

  • exokernels


Program to Process

  • executable format
  • lazy loading
  • paging
  • swapping
  • file descriptors
    • input output error
  • process state
    • running
    • ready
    • blocked
  • register context

Process states

  • Sheduler
  • context switch

  • Non-pre-emptive multi-tasking (sometimes called co-operative multi-tasking - program gets to run until it voluntarily gives control back to the supervisor. (Sometimes used to mean the programs are all scheduled statically to recieve a particular processing time slice.)

  • Normal (pre-emptive) multi-tasking - program gets to run until (approximately) supervisor decides its someone else’s turn.

  • Kernel

    • Handle interrupts
    • Execute priveleged instructions

and Threads

process table


Address space

Memory management




multimedia systems

multiple processor systems

parallel computing

distributed systems






  • Write a shell that is similar to Fig. 1-19 but contains enough code that it actually works so you can test it. You might also add some features such as redirection of input and output, pipes, and background jobs.

  • If you have a personal UNIX-like system (Linux, MINIX, Free BSD, etc.) available that you can safely crash and reboot, write a shell script that attempts to create an unlimited number of child processes and observe what happens. Before running the experiment, type sync to the shell to flush the file system buffers to disk to avoid ruin­ ing the file system. Note: Do not try this on a shared system without first getting per­
    mission from the system administrator. The consequences will be instantly obvious so you are likely to be caught and sanctions may follow.

  • Examine and try to interpret the contents of a UNIX-like or Windows directory with a tool like the UNIX od program or the MS-DOS DEBUG program. Hint: How you do this will depend upon what the OS allows. One trick that may work is to create a di­ rectory on a floppy disk with one operating system and then read the raw disk data using a difef rent operating system that allows such access.

Back to posts

comments powered by Disqus