CPS120: Introduction to Computer Science

Download Report

Transcript CPS120: Introduction to Computer Science

CPS120: Introduction to
Computer Science
Operating Systems
Nell Dale • John Lewis
Operating System
• An operating system manages resources,
and these resources are often shared in one
way or another among programs that want
to use them
Resource Management
• Multiprogramming is the technique of
keeping multiple programs in main memory
at the same time; these programs compete
for access to the CPU so that they can
execute
• Memory management: keeps track of what
programs are in memory and where in
memory they reside
Batch Processing
In early systems, human operators would organize jobs into batches
Timesharing
• A timesharing system allows multiple users to
interact with a computer at the same time
• Multiprogramming allowed multiple processes to
be active at once, which gave rise to the ability for
programmers to interact with the computer system
directly, while still sharing its resources
• In a timesharing system, each user has his or her
own virtual machine, in which all system
resources are (in effect) available for use
Memory Management
• Operating systems must employ techniques
to:
– Track where and how a program resides in
memory
– Convert logical program addresses into actual
memory addresses
Partition Memory Management
• When using fixed partitions, main memory
is divided into a particular number of
partitions
• When using dynamic partitions, the
partitions are created to fit the need of the
programs
Partition Memory Management
• At any point in time memory
is divided into a set of
partitions, some empty and
some allocated to programs
• Base register: a register that
holds the beginning address of
the current partition
• Bounds register: a register
that holds the length of the
current partition
Address resolution
in partition memory
management
Paged Memory Management
• Paged memory technique: main memory
is divided into small fixed-size blocks of
storage called frames.
– A process is divided into pages that we assume
are the same size as a frame
• The operating system maintains a separate
page-map table (PMT) for each process in
memory
Paged Memory Management
A paged memory
management
approach
• To produce a physical
address, you first look up
the page in the PMT to
find the frame number in
which it is stored
• Then multiply the frame
number by the frame size
and add the offset to get
the physical address
Process Management
• The Process States
The process life cycle
The Process Control Block
• The operating system must manage a large
amount of data for each active process
• Usually that data is stored in a data structure
called a process control block (PCB)
– Each state is represented by a list of PCBs, one
for each process in that state
CPU Scheduling
• The act of determining which process in the
ready state should be moved to the running
state
• That is, decide which process should be
given over to the CPU
CPU Scheduling
• Nonpreemptive scheduling: occurs when the currently
executing process gives up the CPU voluntarily
• Preemptive scheduling: occurs when the operating
system decides to favor another process, preempting the
currently executing process
• Turnaround time for a process: amount of time between
the time a process arrives in the ready state to the time it
exits the running state for the last time
Unix
• The operating system is the piece of software that
controls the computer and its resources. An
operating system keeps track of users, filenames
and their location, and manages the computer's
memory.
• Other operating system functions include the
allocation and monitoring of all devices and
scheduling users' programs and tasks.
• Also, the operating system provides an interface to
the user so that the user can write programs, run
programs and access various computer resources.
Shell
• Part of the unix operating system, the shell
program, performs the user interface; it
takes your typed request (command) and
decides what operation to perform. The
commands are short, but powerful.
Search for Telnet
• At RUN in the START box, type
telnet cidermill.wccnet.org
open cidermill.wccnet.org
• Type this at the prompt >
Logon
• Login
• Password
• Change password
– passwd
date
• Type this command at the bash prompt > to
find out the system time and date
pwd
• Finds current directory
echo $PATH
• Finds the current path that the computer
uses to search for files
ls -la
• Lists the files that you have in your current
directory with details of their creation and
details on the associated permissions.
ls *.cpp
• Lists all files with a suffix of cpp
– I.e. those that contain C++ code
cp myprog.cpp newprog.cpp
• Copies and existing file to a new file name
in the existing directory
ls myprog*.*
• Lists all files that start with myprog and
have a period in their name
– This eliminates any directories
pwd
• Relists the contents of the working directory
mkdir programs
• Creates a new DIRECTORY within the
current working directory
cd /home/faculty/pmillis/programs
• Changes the current directory to the
directory we created in the previous
command
pwd
• Lists the name of the current directory. We
will now be in the directory created
ls
• Lists the name of the current directory. We
will now be in the directory created
– Will be empty
lpstat
• Shows the status of the system printer
rm myprog.cpp
• Removes the program we created (delete)
rmdir programs
• Removes (deletes) the directory we created
ls -la
• Lists the contents of the working directory
to ensure that we have properly deleted our
library and file
exit
• Gets us out of UNIX