You are on page 1of 16

Bilgisayar Donanımı

System Software
System Software
Nizamettin AYDIN
naydin@yildiz.edu.tr
http://www.yildiz.edu.tr/~naydin

Introduction Operating Systems - Objectives and Functions

• Convenience
• The biggest and fastest computer in the world —An operating system makes a computer easier
is of no use if it cannot efficiently provide to use
beneficial services to its users. • Efficiency
• Users see the computer through their —An operating system allows better use of
application programs. These programs are computer resources
ultimately executed by computer hardware.
• System software-- in the form of operating
systems and middleware-- is the glue that
holds everything together.

3 4

Layers and Views of a Computer System Operating System Services


• Program creation
• Program execution
• Access to I/O devices
• Controlled access to files
• System access
• Error detection and response
• Accounting

5 6

1
O/S as a Resource Manager Main Resources managed by the O/S
• A computer is a set of resources for the
movement, storage, and processing of
data and for the control of these functions
• The O/S is responsible for managing these
resources
• O/S is a program executed by the
processor
• The O/S frequently relinquishes control
and must depend on the processor to
allow it to regain control

7 8

Types of Operating System Early Systems

• Interactive • Late 1940s to mid 1950s


—User/programmer interacts directly with the —No Operating System
computer through a keyboard/display terminal —Programs interact directly with hardware
• Batch • Two main problems:
—Opposite of interactive. Rare —Scheduling:
• Single program (Uni-programming) —Setup time
—Works only one program at atime
• Multi-programming (Multi-tasking)
—Processor works on more than one program at
a time

9 10

Simple Batch Systems Memory Layout for Resident Monitor


• Resident Monitor program
• Users submit jobs to operator
• Operator batches jobs
• Monitor controls sequence of events to
process batch
• When one job is finished, control returns
to Monitor which reads next job
• Monitor handles scheduling

11 12

2
Multi-programmed Batch Systems Multi-programmed Batch Systems

• Following illustrates the problem:


— The calculation concerns a program that processes a
• I/O devices very slow file of records
• When one program is waiting for I/O, — and performs, on average, 100 processor instructions
per record.
another can use the CPU
• In this example the computer spends over 96%
of its time waiting for I/O devices to finish
transferring data.

System utilization example

13 14

Single Program Multi-Programming with Two Programs

15 16

Multi-Programming with Three Programs Example- benefits of mutiprogramming


• Consider a computer with 250 MBytes of
memory, a disk, a terminal, and a printer.
— Three programs, JOB1, JOB2, and JOB3, are submitted
for execution at the same time with the following
attributes:

• We assume minimal processor requirements for


JOB2 and JOB3, and continuous disk and printer
use by JOB3.
• For a simple batch environment, these jobs will
be executed in sequence
17 18

3
Effects of Multiprogramming on Resource
Utilization histograms Utilization

19 20

Operating Systems Operating Systems

• The evolution of operating systems has paralleled • In the 1960s, hardware has become powerful
the evolution of computer hardware. enough to accommodate multiprogramming,
—As hardware became more powerful, operating —the concurrent execution of more than one task.
systems allowed people to more easily manage
the power of the machine. • Multiprogramming is achieved by allocating each
• In the days when main memory was measured in process a given portion of CPU time (a timeslice).
kilobytes, and tape drives were the only form of • Interactive multiprogramming systems were
magnetic storage, operating systems were simple called timesharing systems.
resident monitor programs. —When a process is taken from the CPU and
—The resident monitor could only load, execute, replaced by another, we say that a context
and terminate programs. switch has occurred.

21 22

Operating Systems Operating Systems

• Today, multiprocessor systems have become • Loosely coupled multiprocessor systems have
commonplace. physically separate memory.
—They present an array of challenges to the —These are often called distributed systems.
operating system designer,
– including the manner in which the processors will be
—Another type of distributed system is a
synchronized, networked system, which consists of a
– and how to keep their activities from interfering with collection of interconnected, collaborating
each other. workstations.
• Tightly coupled multiprocessor systems share a
• Real time operating systems control computers that
common memory and the same set of I/O devices.
respond to their environment.
—Symmetric multiprocessor systems are tightly
coupled and load balanced. —Hard real time systems have tight timing
constraints, soft real time systems do not.

23 24

4
Operating Systems Operating Systems

• Personal computer operating systems are designed • Operating systems having graphical user interfaces
for ease of use rather than high performance. were first brought to market in the 1980s.
• The idea that revolutionized small computer • At one time, these systems were considered
operating systems was the BIOS appropriate only for desktop publishing and games.
—(basic input-output operating system) chip that permitted a • Today they are seen as technology enablers for
single operating system to function on different types of users with little formal computer education.
small systems. • Once solely a server operating system, Linux holds
—The BIOS takes care of the details involved in the promise of bringing Unix to ordinary desktop
addressing divergent peripheral device designs systems.
and protocols.

25 26

Operating Systems Operating Systems

• Two operating system components are crucial: • Microkernel systems provide better security,
— The kernel
easier maintenance, and portability at the expense
— and the system programs.
of execution speed.
• As the core of the operating system, the kernel performs
– scheduling, —Examples are Windows 2000, Mach, and
– synchronization, QNX.
– memory management, —Symmetric multiprocessor computers are
– interrupt handling ideal platforms for microkernel operating
– and it provides security and protection. systems.
• Microkernel systems provide minimal functionality, with most
services carried out by external programs. • Monolithic systems give faster execution speed,
• Monolithic systems provide most of their services within a but are difficult to port from one architecture to
single operating system program.
another.
—Examples are Linux, MacOS, and DOS.
27 28

Operating Systems Operating Systems

• Process management lies at the heart of operating • The operating system schedules process execution.
system services. • First, the operating system determines which process
—The operating system creates processes, shall be granted access to the CPU.
schedules their access to resources, deletes —This is long-term scheduling.
processes, and deallocates resources that were • After a number of processes have been admitted, the
allocated during process execution. operating system determines which one will have
• The operating system monitors the activities of each access to the CPU at any particular moment.
process to avoid synchronization problems that can —This is short-term scheduling.
occur when processes use shared resources. • Context switches occur when a process is taken from
the CPU and replaced by another process.
• If processes need to communicate with one another, —Information relating to the state of the process
the operating system provides the services. is preserved during a context switch.

29 30

5
Scheduling Long Term Scheduling

• Scheduling is key to multi-programming • Determines which programs are


• A process is: submitted for processing
—A program in execution • i.e. controls the degree of multi-
—The “animated spirit” of a program programming
—That entity to which a processor is assigned • Once submitted, a job becomes a process
• Types of scheduling: for the short term scheduler
• (or it becomes a swapped out job for the
medium term scheduler)

31 32

Medium Term Scheduling Short Term Scheduler

• Part of the swapping function • Also known as Dispatcher, executes frequently


• Usually based on the need to manage and makes the fine grained decisions of which job
to execute next
multi-programming
• i.e. which job actually gets to use the processor in
• If no virtual memory, memory the next time slot
management is also an issue • 5 define states in a process state:
—New: A program is admitted by the high-level
schedular but is not yet ready to execute
—Ready: The process is ready to execute
—Running: The prcess is being executed
—Waiting: The process is suspended, waiting for
some system resources
—Halted: The process has terminated and will be
destroyed by the O/S.
33 34

Five State Process Model Process Control Block

• Identifier
• State
• Priority
• Program counter
• Memory pointers
• Context data
• I/O status
• Accounting
information

35 36

6
Scheduling Example Key Elements of O/S for Multiprogramming

37 38

Queuing Diagram Representation of


Operating Systems
Process Scheduling

• Four approaches to CPU scheduling are:


—First-come, first-served where jobs are serviced
in arrival sequence and run to completion if they
have all of the resources they need.
—Shortest job first where the smallest jobs get
scheduled first. (The trouble is in knowing which
jobs are shortest!)
—Round robin scheduling where each job is allotted
a certain amount of CPU time. A context switch
occurs when the time expires.
—Priority scheduling preempts a job with a lower
priority when a higher-priority job needs the CPU.

39 40

Programming Tools Programming Tools

• Programming tools carry out the mechanics of software • The output of most assemblers is a stream of
creation within the confines of the operating system relocatable binary code.
and hardware environment. —In relocatable code, operand addresses are
• Assemblers are the simplest of all programming tools. relative to where the operating system
chooses to load the program.
They translate mnemonic instructions to machine code.
—Absolute (nonrelocatable) code is most
• Most assemblers carry out this translation in two suitable for device and operating system
passes over the source code. control programming.
—The first pass partially assembles the code and
builds the symbol table • When relocatable code is loaded for execution,
—The second pass completes the instructions by special registers provide the base addressing.
supplying values stored in the symbol table. • Addresses specified within the program are
interpreted as offsets from the base address.

41 42

7
Programming Tools Programming Tools

• The process of assigning physical addresses to • On most systems, binary instructions must pass
program variables is called binding. through a link editor (or linker) to create an
• Binding can occur at compile time, load time, or run executable module.
time. • Link editors incorporate various binary routines into
• Compile time binding gives us absolute code. a single executable file as called for by a program’s
• Load time binding assigns physical addresses as external symbols.
the program is loaded into memory. • Like assemblers, link editors perform two passes:
—With load time, binding the program cannot be The first pass creates a symbol table and the
moved! second resolves references to the values in the
• Run time binding requires a base register to carry symbol table.
out the address mapping.

43 “BLGM5519” “BİLGİSAYAR DONANIMI” “BAHÇEŞEHİR ÜNİVERSİTESİ” “GÜZ 2008” “Dr. N AYDIN” 44

Programming Tools Programming Tools

• Dynamic linking is when the link editing is delayed


until load time or at run time.
• External modules are loaded from dynamic link
libraries (DLLs).
• Load time dynamic linking slows down program
loading, but calls to the DLLs are faster.
• Run time dynamic linking occurs when an external
module is first called, causing slower execution time.
—Dynamic linking makes program modules
smaller, but carries the risk that the
programmer may not have control over the
DLL.
45 46

Programming Tools Programming Tools

• Assembly language is considered a “second


generation” programming language (2GL).
• Compiled programming languages, such as C,
C++, Pascal, and COBOL, are “third generation”
languages (3GLs).
• Each language generation presents problem
solving tools that are closer to how people think
and farther away from how the machine
implements the solution.
Keep in mind that the computer can understand only the 1GL!

47 48

8
Programming Tools Programming Tools

• Compilers bridge the semantic gap between the • The last three compiler phases are synthesis
higher level language and the machine’s binary phases:
instructions. 4. Intermediate code generation creates three
address code to facilitate optimization and
• Most compilers effect this translation in a six-phase translation.
process. The first three are analysis phases: 5. Optimization creates assembly code while taking
1. Lexical analysis extracts tokens, e.g., reserved into account architectural features that can make
words and variables. the code efficient.
2. Syntax analysis (parsing) checks statement 6. Code generation creates binary code from the
construction. optimized assembly code.
3. Semantic analysis checks data types and the • Through this modularity, compilers can be written
validity of operators. for various platforms by rewriting only the last two
phases.
49 50

Programming Tools Programming Tools

• Interpreters produce executable code from source


code in real time, one line at a time.
• Consequently, this not only makes interpreted
languages slower than compiled languages but it
also affords less opportunity for error checking.
• Interpreted languages are, however, very useful
for teaching programming concepts, because
feedback is nearly instantaneous, and
performance is rarely a concern.

51 52

Java: All of the Above Java: All of the Above

• The Java programming language exemplifies many of • The JVM is an operating system in miniature.
the concepts that we have discussed in this chapter. —It loads programs, links them, starts execution
threads, manages program resources, and
• Java programs (classes) execute within a virtual deallocates resources when the programs
machine, the Java Virtual Machine (JVM). terminate.
• This allows the language to run on any platform for
which a virtual machine environment has been written.
• Java is both a compiled and an interpreted language.
The output of the compilation process is an assembly-
like intermediate code (bytecode) that is interpreted by
the JVM. • Because the JVM performs so many tasks at run
time, its performance cannot match the performance
of a traditional compiled language.
53 54

9
Database Software Database Software

• Database systems • Database systems provide a single definition,


contain the most the database schema, for the data elements
valuable assets of that are accessed by application programs.
an enterprise. —A physical schema is the computer’s view of
They are the the database that includes locations of
foundation upon physical files and indexes.
which application —A logical schema is the application program’s
systems are built. view of the database that defines field sizes
and data types.
• Within the logical schema, certain data fields
are designated as record keys that provide
efficient access to records in the database.
55 56

Database Software Database Software

• Most database systems also include transaction


• Keys are stored in physical index file structures management components to assure that the database
containing pointers to the location of the physical is always in a consistent state.
records.
• Transaction management provides the following
• Many implementations use a variant of a B+ tree for properties:
index management because B+ trees can be — Atomicity - All related updates occur or no updates
optimized with consideration to the I/O system and occur.
— Consistency - All updates conform to defined data
the applications. constraints.
• In many cases, the “higher” nodes of the tree will — Isolation - No transaction can interfere with another
transaction.
persist in cache memory, requiring physical disk — Durability - Successful updates are written to durable
accesses only when traversing the lower levels of media as soon as possible.
the index. • These are the ACID properties of transaction
management.
57 58

Database Software Database Software

• Record locking mechanisms assure isolated, atomic


• Without the ACID properties, race conditions can database updates:
occur:

59 60

10
Transaction Managers Transaction Managers

• One way to improve database performance is to ask it


to do less work by moving some of its functions to
specialized software.
• Transaction management is one component that is
often partitioned from the core database system.
• Transaction managers are especially important when
the transactions involve more than one physical
database, or the application system spans more than
one class of computer, as in a multitiered architecture.
• One of the most widely-used transaction management
systems is CICS shown on the next slide.

61 62

Conclusion Conclusion

• The proper functioning and performance of a • Programming languages are often classed into
computer system depends as much on its generations, with assembly language being the
software as its hardware. first generation.
• The operating system is the system software • All languages above the machine level must be
component upon which all other software rests. translated into machine code.
• Operating systems control process execution, • Compilers bridge this semantic gap through a
resource management, protection, and security. series of six steps.
• Subsystems and partitions provide compatibility • Link editors resolve system calls and external
and ease of management. routines, creating a unified executable module.

63 64

Conclusion

• The Java programming language incorporates


the idea of a virtual machine, a compiler and an Memory Management
interpreter.
• Database software provides controlled access
to data files through enforcement of ACID
properties.
• Transaction managers provide high
performance and cross-platform access to data.

65
66

11
Memory Management Swapping

• Task of dynamically subdivison of memory • Problem: I/O is so slow compared with


• Effective memory management is vital in a CPU that even in multi-programming
multiprogramming system system, CPU can be idle most of the time
• Uni-program • Solutions:
—Memory split into two —Increase main memory
—One for Operating System (monitor) – Expensive
– Leads to larger programs
—One for currently executing program
—Swapping
• Multi-program
—“User” part is sub-divided and shared among
active processes

67 68

What is Swapping? Use of Swapping

• Long term queue of processes stored on


disk
• Processes “swapped” in as space becomes
available
• As a process completes it is moved out of
main memory
• If none of the processes in memory are
ready (i.e. all I/O blocked)
—Swap out a blocked process to intermediate
queue
—Swap in a ready process or a new process
—But swapping is an I/O process…
69 70

Partitioning Fixed Partitioning

• Splitting memory into sections to allocate


to processes (including Operating System)
• Fixed-sized partitions
—May not be equal size
—Process is fitted into smallest hole that will
take it (best fit)
—Some wasted memory
—Leads to variable sized partitions

71 72

12
Variable Sized Partitions (1) Variable Sized Partitions (2)

• Allocate exactly the required memory to a


process • Eventually have lots of holes
• This leads to a hole at the end of memory, (fragmentation)
too small to use • Solutions:
—Only one small hole - less waste —Coalesce - Join adjacent holes into one large
hole
• When all processes are blocked, swap out
—Compaction - From time to time go through
a process and bring in another memory and move all hole into one free block
• New process may be smaller than (c.f. disk de-fragmentation)
swapped out process
• Another hole

73 74

Effect of Dynamic Partitioning Relocation

• No guarantee that process will load into


the same place in memory
• Instructions contain addresses
—Locations of data
—Addresses for instructions (branching)
• Logical address - relative to beginning of
program
• Physical address - actual location in
memory (this time)
• Automatic conversion using base address

75 76

Paging Allocation of Free Frames

• Split memory into equal sized, small


chunks -page frames
• Split programs (processes) into equal
sized small chunks - pages
• Allocate the required number page frames
to a process
• Operating System maintains list of free
frames
• A process does not require contiguous
page frames
• Use page table to keep track
77 78

13
Logical and Physical Addresses - Paging Virtual Memory

• Demand paging
—Do not require all pages of a process in
memory
—Bring in pages as required
• Page fault
—Required page is not in memory
—Operating System must swap in required page
—May need to swap out a page to make space
—Select page to throw out based on recent
history

79 80

Thrashing Bonus

• Too many processes in too little memory • We do not need all of a process in
• Operating System spends all its time memory for it to run
swapping • We can swap in pages as required
• Little or no real work is done • So - we can now run processes that are
• Disk light is on all the time bigger than total memory available!

• Solutions • Main memory is called real memory


—Good page replacement algorithms • User/programmer sees much bigger
—Reduce number of processes running memory - virtual memory
—Fit more memory

81 82

Segmentation Advantages of Segmentation

• Paging is not (usually) visible to the • Simplifies handling of growing data


programmer structures
• Segmentation is visible to the • Allows programs to be altered and
programmer recompiled independently, without re-
• Usually different segments allocated to linking and re-loading
program and data • Lends itself to sharing among processes
• May be a number of program and data • Lends itself to protection
segments • Some systems combine segmentation
with paging

83 84

14
Pentium II Pentium II Address Translation Mechanism
• Hardware for segmentation and paging
• Unsegmented unpaged
— virtual address = physical address
— Low complexity
— High performance
• Unsegmented paged
— Memory viewed as paged linear address space
— Protection and management via paging
— Berkeley UNIX
• Segmented unpaged
— Collection of local address spaces
— Protection to single byte level
— Translation table needed is on chip when segment is in
memory
• Segmented paged
— Segmentation used to define logical memory partitions subject
to access control
— Paging manages allocation of memory within partitions
— Unix System V
85 86

Pentium II Segmentation Pentium II Protection

• Each virtual address is 16-bit segment


and 32-bit offset • Protection bits give 4 levels of privilege
• 2 bits of segment are protection —0 most protected, 3 least
mechanism —Use of levels software dependent
—Usually level 3 for applications, level 1 for O/S
• 14 bits specify segment and level 0 for kernel (level 2 not used)
• Unsegmented virtual memory 232 = —Level 2 may be used for apps that have
4Gbytes internal security e.g. database
• Segmented 246=64 terabytes —Some instructions only work in level 0
—Can be larger – depends on which process is
active
—Half (8K segments of 4Gbytes) is global
—Half is local and distinct for each process
87 88

Pentium II Paging PowerPC Memory Management Hardware

• Segmentation may be disabled • 32 bit – paging with simple segmentation


—In which case linear address space is used —64 bit paging with more powerful segmentation
• Two level page table lookup • Or, both do block address translation
—First, page directory —Map 4 large blocks of instructions & 4 of
– 1024 entries max memory to bypass paging
– Splits 4G linear memory into 1024 page groups of —e.g. OS tables or graphics frame buffers
4Mbyte • 32 bit effective address
– Each page table has 1024 entries corresponding to
—12 bit byte selector
4Kbyte pages
– =4kbyte pages
– Can use one page directory for all processes, one per
process or mixture —16 bit page id
– Page directory for current process always in memory – 64k pages per segment
—Use TLB holding 32 page table entries —4 bits indicate one of 16 segment registers
– Segment registers under OS control
—Two page sizes available 4k or 4M

89 90

15
PowerPC 32-bit Memory Management Formats PowerPC 32-bit Address Translation

91 92

16

You might also like