Vous êtes sur la page 1sur 43

Computer Organization and

Assembly Language
Muhammad Usman
Operating System Support
• Sits between User’s
Applications and Hardware
• Enables applications to use
hardware
• Control and supervises
computer system
• Provide the programmer a
convenient interface for
using the system
FUUAST, Islamabad 2
Services Provided by OS
• Program creation
– Editor and debuggers
– Utility programs as part of OS
• Program execution
– Instruction and data loaded into memory
– I/O devices and files must be initialized
– Resources must be prepared

FUUAST, Islamabad 3
Continue…
• Access to I/O devices
– Each device has its own set of instructions
– Different control signal for operation
– Programmer need simple reads and writes
• Controlled access to files
– File formats
– Nature of I/O devices
– Protection to access control for no. of users

FUUAST, Islamabad 4
Continue…
• System access
– Shared or public system
– Protection of resources and data from
unauthorized users
– Resolve conflict of resources
• Accounting
– Usage statistics
– Performance parameters, like response time
– Anticipating in future enhancements

FUUAST, Islamabad 5
Continue…
• Error detection and response
– Internal & External Hardware Errors
• Memory error
• Device failure
– Software Errors
• Arithmetic overflow
• Access forbidden memory location
• Inability to grant access to application
– OS responses to clear the error condition

FUUAST, Islamabad 6
Continue…
– Error response can be:
• Ending the program that caused error
• Retrying the operation or
• Simply reporting the error to the application

FUUAST, Islamabad 7
Functions of OS
• Process Management
– Multiple processes at the time
– Allocate resources to processes
– Protects resources of one process from other
• Memory Management
– Allocating main memory space
– Freeing memory for reuse
– Protection of memory locations

FUUAST, Islamabad 8
Continue…
• I/O Management
– Controlling operations of all the I/O devices
– I/O controller to manage and coordinate the
operation
• File Management
– Keeping track of files and folders
– Common operations; creating, opening,
editing, renaming, moving, copying, deleting
and searching files
FUUAST, Islamabad 9
Continue…
• Resource Management
– CPU, memory and other devices
– Efficient allocation of resources
• User Management
– Administrative control
– Managing user accounts
– Policies

FUUAST, Islamabad 10
Types of OS
• Batch Processing
– Jobs are grouped in batches
– Collects the programs and data together in a
batch before processing
– Jobs are processed in the order of submission
– Increased performance

FUUAST, Islamabad 11
Continue…
• Time Sharing
– User programs are executed simultaneously
– CPU is switched rapidly between the programs
– Switches occur so frequently that the users
may interact with each program while it is
running
– When a process executes, it executes for only
a very short time before it either finishes or
needs to perform I/O

FUUAST, Islamabad 12
Continue…
• Real-Time
– Process information and produce a response
within a specified time
– Immediate response
– Usually embedded systems
– Typically read from and react to sensor data

FUUAST, Islamabad 13
Scheduling
• Key to multiprogramming
• Aim is to make the system efficient
• Process is program in execution
• Allows one process to use the CPU while
the execution of another process is on
hold

FUUAST, Islamabad 14
Continue…

FUUAST, Islamabad 15
Continue…
• New
– Admitted by scheduler, OS will initialize the
process
• Ready
– Ready to execute and is awaiting access to CPU
• Running
– Executed by the processor
• Blocked
– Suspended from execution waiting for some I/O
• Exit
– Terminated and will be destroyed by the OS
FUUAST, Islamabad 16
Process Control Block
• OS maintain information of each process
– Each process is represented in the OS by PCB
– Data structure containing group of all
necessary information about a particular
process
– Indicate the state of the process
– Other information necessary for execution

FUUAST, Islamabad 17
Continue…

FUUAST, Islamabad 18
Continue…
• PCB contains:
– Identifier/process ID: unique identifier
– State: current state (new, ready, etc.)
– Priority: priority level
– Program counter: address of next instruction
– Memory pointer: start and end locations in
memory
– Context data: data present in registers

FUUAST, Islamabad 19
Memory Management
• Uniprogramming system
– Memory is divided into two parts
• One for OS
• Other for program currently executing
• Multiprogramming system
– “User” part of memory is subdivided
– Subdivision is carried out dynamically by OS

FUUAST, Islamabad 20
Swapping
• A mechanism in which a process can be
swapped temporarily out of main memory
to secondary storage and
• Make that memory available to other
processes
• At some later time, the system swaps back
the process from the secondary storage to
main memory

FUUAST, Islamabad 21
Continue…

FUUAST, Islamabad 22
Continue…
• Performance is usually affected by
swapping process
• But it helps in running multiple and big
processes in parallel
• Swapping is also known as a technique for
memory compaction
• Used when the memory is full

FUUAST, Islamabad 23
Fragmentation
• As processes are loaded and removed
from memory, the free memory space is
broken into little pieces
• Coming processes cannot be allocated to
memory blocks because of small size
• Memory blocks remains unused
• Internal and external fragmentation

FUUAST, Islamabad 24
Continue…

FUUAST, Islamabad 25
Continue…

FUUAST, Islamabad 26
Continue…
• External fragmentation
– Total memory space is enough to satisfy a
request or to reside a process in it, but it is not
contiguous, so it cannot be used
• Internal fragmentation
– Memory block assigned to process is bigger.
Some portion of memory is left unused, as it
cannot be used by another process.

FUUAST, Islamabad 27
Paging
• Computer can address more memory than
the amount of physically memory
• Extra memory is actually called virtual
memory
• Paging plays an important role in
implementing virtual memory
• Technique in which process address space
is broken into blocks of the same size
called pages
FUUAST, Islamabad 28
Continue…
• Divide each process in the form of pages
• Main memory is divided into small fixed-
sized blocks called frames
• Size of a frame is kept the same as that of
a page to avoid fragmentation
• Pages of the process are brought into the
main memory only when they are required
• Different operating systems defines
different frame sizes
FUUAST, Islamabad 29
Continue…

FUUAST, Islamabad 30
Segmentation
• Each job is divided into several segments
of different sizes
• When a process is to be executed, its
corresponding segmentation are loaded
into memory
• Similar to paging but segments are of
variable-length
• OS maintains segment map table for every
process
FUUAST, Islamabad 31
Instruction Representation

• Instruction is divided into fields


• CPU extract data from various instruction
fields
• During execution, instruction is read into
Instruction Register
FUUAST, Islamabad 32
Instruction Types
• Data Processing
– Arithmetic and logic instructions
– Arithmetic instructions provide computational
capabilities
– Add, subtract, multiply, or divide on contents
of registers
– Logic instructions provide logical comparisons
– AND, NOT, OR, bitwise operations, shift
instructions
FUUAST, Islamabad 33
Continue…
• Data Storage
– Data moving into or out of register or memory
– Instructions cause transfer of data from one
location to another
– Load/store data from memory to register
• Data Movement
– I/O instructions
– Read and write data from hardware devices

FUUAST, Islamabad 34
Continue…
• Control
– Test and branch instructions
– Test instructions are used to test the value of a
data word or the status of a computation
– Branch instructions are used to branch to a
different set of instructions depending on the
decision made

FUUAST, Islamabad 35
Address Scheme
• Three address instruction
– Operand 1, Operand 2, Result
–X=A*B
– MUL X, R1, R2
– Short program
– Too many bits to specify three addresses

FUUAST, Islamabad 36
Continue…
• Two address instruction
– Common in commercial computers
– MOV R1, A
– Reduce length of instruction
– Temporary storage hold results
• One address instruction
– Use accumulator register for data
manipulation
– LOAD A

FUUAST, Islamabad 37
Continue…
• Zero address instruction
– Stack organized computer does not use
address field
– PUSH and POP

FUUAST, Islamabad 38
Communication
• Computer network
– A set of computers connected together for the
purpose of sharing resources
• Internet
– A global computer network providing a variety
of information and communication facilities

FUUAST, Islamabad 39
Continue…
• Communication can be wired or wireless
• Different types of networks
• MAC and IP address play vital role
– MAC is hardware identification number that
uniquely identifies each device on a network
– IP is unique numerical label separated by full
stops that identifies each computer using the
Internet Protocol to communicate

FUUAST, Islamabad 40
OSI Model for Communication
• Physical (e.g., copper, fiber, etc.)
• Data link (e.g., Ethernet, PPP, FDDI, etc.)
• Network (e.g., IPv4, IPv6, IPX, etc.)
• Transport (e.g., TCP, UDP, etc.)
• Session (establish, control, end session)
• Presentation (e.g., ASCII vs. EBCDIC etc.)
• Application (e.g., HTTP, SMTP, DNS, etc.)

FUUAST, Islamabad 41
Continue…

FUUAST, Islamabad 42
Network Devices
• Components used to connect computers
or other devices
• Devices used to setup networks (LAN,
WAN etc.)
• Works on different layers of OSI model
• Hub, switch, modem, router, bridge,
repeater

FUUAST, Islamabad 43

Vous aimerez peut-être aussi