0% found this document useful (0 votes)
15 views

4Computer System Operation

The document outlines the operation of computer systems, detailing the startup process, BIOS functions, boot loaders, and kernel initialization. It explains system calls as the primary interface between applications and the operating system, including their implementation and parameter passing methods. Additionally, it discusses virtualization, its benefits, and the concept of virtual machines, emphasizing the abstraction of computing resources.

Uploaded by

aaditkrishnaa18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

4Computer System Operation

The document outlines the operation of computer systems, detailing the startup process, BIOS functions, boot loaders, and kernel initialization. It explains system calls as the primary interface between applications and the operating system, including their implementation and parameter passing methods. Additionally, it discusses virtualization, its benefits, and the concept of virtual machines, emphasizing the abstraction of computing resources.

Uploaded by

aaditkrishnaa18
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Computer System Operation

System Startup
• On power up
• everything in system is in random, unpredictable state
• special hardware circuit raises RESET pin of CPU
• sets the program counter to 0xfffffff0
• this address is mapped to ROM (Read-Only Memory)
• BIOS (Basic Input/Output Stream)
• set of programs stored in ROM
• some OS’s use only these programs
• MS DOS
• many modern systems use these programs to load other system programs
• Windows, Unix, Linux
BIOS
• General operations performed by BIOS
1) find and test hardware devices
- POST (Power-On Self-Test)
2) initialize hardware devices
- creates a table of installed devices
3) find boot sector
- may be on floppy, hard drive, or CD-ROM
4) load boot sector into memory location 0x00007c00
5) sets the program counter to 0x00007c00
- starts executing code at that address
Boot Loader
• Small program stored in boot sector
• Loaded by BIOS at location 0x00007c0
• Configure a basic file system to allow system to read from disk
• Loads kernel into memory
• Also loads another program that will begin kernel initialization
Initial Kernel Program
• Determines amount of RAM in system
• uses a BIOS function to do this
• Configures hardware devices
• video card, mouse, disks, etc.
• BIOS may have done this but usually redo it
• portability

• Switches the CPU from real to protected mode


• real mode: fixed segment sizes, 1 MB memory addressing, and no segment protection
• protected mode: variable segment sizes, 4 GB memory addressing, and provides segment
protection
• Initializes paging (virtual memory)
Final Kernel Initialization
• Sets up page tables and segment descriptor tables
• these are used by virtual memory and segmentation hardware
• Sets up interrupt vector and enables interrupts
• Initializes all other kernel data structures ( Linked lists, Binary search
trees, Bitmaps etc.)
• Creates initial process and starts it running
• init in Linux
• smss (Session Manager SubSystem) in NT
Booting
System Programs
• Application programs included with the OS
• Highly trusted programs
• Perform useful work that most users need
• listing and deleting files, configuring system
• ls, rm, Windows Explorer and Control Panel
• may include compilers and text editors
• Not part of the OS
• run in user space
• Very useful
Operating-System Operations
• Interrupt driven by hardware
• Software error or request creates exception or trap
• Division by zero, request for operating system service
• Other process problems include infinite loop, processes modifying each other or the operating system
• Dual-mode operation allows OS to protect itself and other system components
• Hardware provides at least two modes:
• “Kernel” mode (or “supervisor” or “protected”)
• “User” mode: Normal programs executed
• Mode bit provided by hardware
• Provides ability to distinguish when system is running user code or kernel code
• Some instructions designated as privileged, only executable in kernel mode
• System call changes mode to kernel, return from call resets it to user
Dual Mode Operation
• Some instructions/ops prohibited in user mode:
• Example: cannot modify page tables in user mode
• Attempt to modify  Exception generated
• Transitions from user mode to kernel mode:
• System Calls, Interrupts, Other exceptions
Transition from User to Kernel Mode
• Timer to prevent infinite loop / process hogging resources
• Set interrupt after specific period
• Operating system decrements counter
• When counter zero generate an interrupt
• Set up before scheduling process to regain control or terminate program that
exceeds allotted time
Standard C Library Example
• C program invoking printf() library call, which calls
write() system call
System Calls
• System calls provide the interface between a running program and the
operating system.
• Generally available as assembly-language instructions.
• Languages have been defined to replace assembly language for systems
programming; allow system calls to be made directly (e.g., C, C++)
• Three general methods are used to pass parameters between a running
program and the operating system.
• Pass parameters in registers.
• Store the parameters in a table in memory, and the table address is passed as a
parameter in a register.
• Push (store) the parameters onto the stack by the program, and pop off the stack by
operating system.
System Calls
• System calls are routines run by the OS on behalf of the user
• Allow user to access I/O, create processes, get system information,
etc.
• Programming interface to the services provided by the OS
• Typically written in a high-level language (C or C++)
• Mostly accessed by programs via a high-level Application
Programming Interface (API) rather than direct system call use
• Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux,
and Mac OS X), and Java API for the Java virtual machine (JVM)
System Calls

• A System Call is the main way a user program interacts with the Operating System.
System Calls

HOW A SYSTEM CALL WORKS

 Obtain access to system space


 Do parameter validation
 System resource collection ( locks on structures )
 Ask device/system for requested item
 Suspend waiting for device
 Interrupt makes this thread ready to run
 Wrap-up
 Return to user
There are 11 (or more) steps in making the system call Linux API
read (fd, buffer, nbytes)
System Call Implementation
• Typically, a number associated with each system call
• System-call interface maintains a table indexed according to these numbers
• The system call interface invokes the intended system call in OS
kernel and returns status of the system call and any return values
• The caller need to know nothing about how the system call is
implemented
• Just needs to obey API and understand what OS will do as a result call
• Most details of OS interface hidden from programmer by API
• Managed by run-time support library (set of functions built into libraries included with
compiler)
Example of Standard API
Example of Windows API

• Consider the ReadFile() function in the program


• Win32 API—a function for reading from a file.

• A description of the parameters passed to ReadFile()


• HANDLE file—the file to be read
• LPVOID buffer—a buffer where the data will be read into and written from
• DWORD bytesToRead—the number of bytes to be read into the buffer
• LPDWORD bytesRead—the number of bytes read during the last read
• LPOVERLAPPED ovl—indicates if overlapped I/O is being used
API – System Call – OS Relationship
System Call Parameter Passing
• Often, more information is required than simply identity of desired system
call
• Exact type and amount of information vary according to OS and call
• Three general methods used to pass parameters to the OS
• Simplest: pass the parameters in registers
• In some cases, may be more parameters than registers
• Parameters stored in a block, or table, in memory, and address of block passed as a
parameter in a register
• This approach taken by Linux and Solaris
• Parameters placed, or pushed, onto the stack by the program and popped off the
stack by the operating system
• Block and stack methods do not limit the number or length of parameters being
passed
passing data between programs

Msg Passing Shared Memory


Passing of Parameters As A Table
Example of System Calls
• System call sequence to copy the contents of one file to another file
Send message from one processor to another
Operations to be performed:
Source Dest User-Level Code
• Check Permissions, Format Message Program Program (With Libraries)
• Enforce forward progress,
Handle interrupts
SysCall SysCall
• Prevent Denial Of Service (DOS)
and/or Deadlock
Message Kernel (OS) Message
OS Service
Traditional Approach: Service Code Service
Use a system call + OS Service
Device Device
Driver Driver
Hardwar Hardwar
e e
Network Hardware
Interfac Interfac
e e
UNIX System Structure
Applications
User Mode
Standard Libs

Kernel Mode

Hardware
Linux Structure
Microsoft Windows Structure
Major Windows Components
• Hardware Abstraction Layer
• Hides hardware chipset differences from upper levels of OS
• Kernel Layer
• Thread Scheduling
• Low-Level Processors Synchronization
• Interrupt/Exception Handling
• Switching between User/Kernel Mode.
• Executive
• Set of services that all environmental subsystems need
• Object Manager
• Virtual Memory Manager
• Process Manager
• Advanced Local Procedure Call Facility
• I/O manager
• Cache Manager
• Security Reference Monitor
• Plug-and-Plan and Power Managers
• Registry
• Booting
• Programmer Interface: Win32 API
Types of System Calls
• Process control
• File manipulation
• Device manipulation
• Information maintenance
• Communications
• Protection
Types of System Calls
• Process control
• create process, terminate process
• end, abort
• load, execute
• get process attributes, set process attributes
• wait for time
• wait event, signal event
• allocate and free memory
• Dump memory if error
• Debugger for determining bugs, single step execution
• Locks for managing access to shared data between processes
Types of System Calls
• File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes
• Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
Types of System Calls
• Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
• Communications
• create, delete communication connection
• send, receive messages if message passing model to host name or process
name
• From client to server
• Shared-memory model create and gain access to memory regions
• transfer status information
• attach and detach remote devices
Types of System Calls
• Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Examples of Windows and Unix System Calls
Initial Hardware Model
The host machine is equipped with the physical hardware
e.g. a desktop with x-86 architecture running its installed Windows OS
All applications access hardware resources (i.e. memory, i/o) through system calls to operating
system (privileged instructions)
• Single OS image per machine
• Software and hardware tightly coupled
• Running multiple applications on same machine
• Underutilized resources
• Inflexible and costly infrastructure
• Advantages
• Design is decoupled (i.e. OS people can develop OS separate of Hardware
people developing hardware)
• Hardware and software can be upgraded without notifying the Application
programs
• Disadvantages
• Application compiled on one ISA will not run on another ISA..
• Applications compiled for Mac use different operating system calls then
application designed for windows.
• ISA’s must support old software
• Can often be inhibiting in terms of performance
• Since software is developed separately from hardware..
• Software is not necessarily optimized for hardware.
Architecture & Interfaces
Architecture: formal specification of a system’s interface and the logical behavior of its visible
resources.

Applications
API
Libraries
System Calls
ABI
Operating
System

ISA
System ISA User ISA

Hardware

 API – Application Programming Interface


 ABI – Application Binary Interface
 ISA – Instruction Set Architecture
Architecture, Implementation Layers
• Architecture
• Functionality and Appearance of a computer system but not implementation details
• Level of Abstraction = Implementation layer ISA, ABI, API
Architecture, Implementation Layers
• Implementation Layer : ISA
• Instruction Set Architecture
• Divides hardware and software
• Concept of ISA originates from IBM 360
• Various prices, processing power, processing unit, devices
• But guarantee a software compatibility
• User ISA and System ISA
Architecture, Implementation Layers
• Implementation Layer : ABI
• Application Binary Interface
• Provides a program with access to the hardware resource and services
available in a system
• Consists of User ISA and System Call Interfaces
Architecture, Implementation Layers
• Implementation Layer : API
• Application Programming Interface
• Key element is Standard Library ( or Libraries )
• Typically defined at the source code level of High Level Language
• clib in Unix environment : supports the UNIX/C programming language
Multimode System
• The concept of modes of operation in operating system can be
extended beyond the dual mode. This is known as the
multimode system. In those cases the more than 1 bit is used
by the CPU to set and handle the mode.
• An example of the multimode system can be described by the
systems that support virtualization. These CPU’s have a
separate mode that specifies when the virtual machine manager
(VMM) and the virtualisation management software is in control
of the system.
• For these systems, the virtual mode has more privileges than
user mode but less than kernel mode.
What is virtualization?
• Virtualization -- the abstraction of computer resources.

• Virtualization hides the physical characteristics of computing resources from their


users, be they applications, or end users.

• This includes making a single physical resource (such as a server, an operating


system, an application, or storage device) appear to function as multiple virtual
resources; it can also include making multiple physical resources (such as storage
devices or servers) appear as a single virtual resource.
Virtualization

• Similar to Abstraction but doesn’t always hide low layer’s details


• Real system is transformed so that it appears to be different
• Virtualization can be applied not only to subsystem, but to an Entire Machine
→ Virtual Machine
Virtualization

Applications or OS

Application uses virtual disk as Real disk

Virtualized
Disk

Virtualization

File File

Abstraction

Real Disk
• Virtualization, in computing, is the creation of a virtual (rather than actual)
version of something, such as a hardware platform, operating system, storage
device, or network resources.
• Virtualization is the process by which one computer hosts the appearance of
many computers.
• It is used to improve IT throughput and costs by using physical resources as a pool
from which virtual resources can be allocated.
VIRTUALIZATION BENEFITS
• Sharing of resources helps cost reduction
• Isolation: Virtual machines are isolated from each other as if they are physically
separated
• Encapsulation: Virtual machines encapsulate a complete computing environment
• Hardware Independence: Virtual machines run independently of underlying
hardware
• Portability: Virtual machines can be migrated between different hosts.
• Cross platform compatibility
• Increase Security
• Enhance Performance
• Simplify software migration
What is “Machine”?
• 2 perspectives
• From the perspective of a process
• ABI provides interface between process and machine

• From the perspective of a system


• Underlying hardware itself is a machine.
• ISA provides interface between system and machine
System/Process Virtual Machines
Can view virtual machine as:
• Process virtual machine
• Virtual machines can be instantiated for a single program (i.e. similar to Java)
• Virtual machine terminates when process terminates.
• System virtual machine (i.e. similar to cygwin)
• Full execution environment that can support multiple processes
• Support I/O devices
• Support GUI
Virtual Machines
• A virtual machine takes the layered approach to its logical conclusion.
It treats hardware and the operating system kernel as though they
were all hardware.
• A virtual machine provides an interface identical to the underlying
bare hardware.
• The operating system creates the illusion of multiple processes, each
executing on its own processor with its own (virtual) memory.
• The resources of the physical computer are shared to create the
virtual machines.
• CPU scheduling can create the appearance that users have their own
processor.
• Spooling (simultaneous peripheral operations online) and a file system can
provide virtual card readers and virtual line printers.
• A normal user time-sharing terminal serves as the virtual machine operator’s
console.
VM types
• Native VM
• Hosted VM
• Dual mode VM
Native VM
• The VM can be provisioned to any hardware system.
• Virtual software placed between underlying machine and conventional software
• Conventional software sees different ISA from the one supported by the
hardware
• The VM is built with virtual resources managed by a guest OS to run a specific
application. Between the VMs and the host platform, we need to deploy a
middleware layer called a Virtual Machine Monitor (VMM) .
• Figure b shows a native VM installed with the use a VMM called a
hypervisor at the privileged mode.
• For example, the hardware has a x-86 architecture running the
Windows system. The guest OS could be a Linux system and the hypervisor
is the XEN system developed at Cambridge University.
• This hypervisor approach is also called bare-metal VM, because the
hypervisor handles the bare hardware (CPU, memory, and I/O) directly.
• Virtualization process involves:
• Mapping of virtual resources (registers and memory) to real hardware
resources
• Using real machine instructions to carry out the actions specified by the
virtual machine instructions
Hosted VM

Another architecture is the host VM


shown in Fig. (c). Here the VMM runs
with a non-privileged mode. The host OS
need not be modified.
Dual Mode VM

The VM can be also implemented with a dual mode


as shown in Fig. (d).
• Part of VMM runs at the user level and another portion runs at the
supervisor level. In this case, the host OS may have to be modified to
some extent.
• Multiple VMs can be ported to one given hardware system, to support
the virtualization process.
• The VM approach offers hardware-independence of the OS and
applications.
• The user application and its dedicated OS could be bundled together
as a virtual appliance, that can be easily ported on various hardware
platforms.
System Models
Advantages/Disadvantages of Virtual
Machines
• The virtual-machine concept provides complete protection of system
resources since each virtual machine is isolated from all other virtual
machines. This isolation, however, permits no direct sharing of
resources.
• A virtual-machine system is a perfect vehicle for operating-systems
research and development. System development is done on the
virtual machine, instead of on a physical machine and so does not
disrupt normal system operation.
• The virtual machine concept is difficult to implement due to the effort
required to provide an exact duplicate to the underlying machine.

You might also like