CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

35
CPS120: Introduction to Computer Science Operating Systems Nell Dale • John Lewis

Transcript of CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Page 1: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

CPS120: Introduction to Computer Science

Operating Systems

Nell Dale • John Lewis

Page 2: 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

Page 3: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 4: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Batch Processing

In early systems, human operators would organize jobs into batches

Page 5: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 6: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 7: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 8: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 9: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 10: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Paged Memory Management

• 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 addressA paged memory

management approach

Page 11: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Process Management

• The Process States

The process life cycle

Page 12: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 13: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 14: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 15: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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.

Page 16: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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.

Page 17: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Search for Telnet

• At RUN in the START box, type telnet cidermill.wccnet.org

Page 18: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

open cidermill.wccnet.org

• Type this at the prompt >

Page 19: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

Logon

• Login

• Password

• Change password– passwd

Page 20: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

date

• Type this command at the bash prompt > to find out the system time and date

Page 21: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

pwd

• Finds current directory

Page 22: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

echo $PATH

• Finds the current path that the computer uses to search for files

Page 23: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

ls -la

• Lists the files that you have in your current directory with details of their creation and details on the associated permissions.

Page 24: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

ls *.cpp

• Lists all files with a suffix of cpp– I.e. those that contain C++ code

Page 25: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

cp myprog.cpp newprog.cpp

• Copies and existing file to a new file name in the existing directory

Page 26: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

ls myprog*.*

• Lists all files that start with myprog and have a period in their name– This eliminates any directories

Page 27: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

pwd

• Relists the contents of the working directory

Page 28: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

mkdir programs

• Creates a new DIRECTORY within the current working directory

Page 29: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

cd /home/faculty/pmillis/programs

• Changes the current directory to the directory we created in the previous command

Page 30: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

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

Page 31: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

lpstat

• Shows the status of the system printer

Page 32: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

rm myprog.cpp

• Removes the program we created (delete)

Page 33: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

rmdir programs

• Removes (deletes) the directory we created

Page 34: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

ls -la

• Lists the contents of the working directory to ensure that we have properly deleted our library and file

Page 35: CPS120: Introduction to Computer Science Operating Systems Nell Dale John Lewis.

exit

• Gets us out of UNIX