programs - Computer Science

Download Report

Transcript programs - Computer Science

Introduction to Computer Science
CSCI 150 Section 002
Session 25
Dr. Richard J. Bonneau
IONA Technologies
[email protected]
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
1
Today’s Outline
 Today’s ‘notices’
 Tonight’s Topics
– Chapter 10 - Virtual Environments for Computing
– AKA ‘Operating Systems’
 Next Class Topic
– Chapter 11 - Computer Communications
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
2
Today’s Notices
 Office
 Extension
 Office hours
 E-mail
Swords 339
2284
Tu-Th 4-6:30 and after class
[email protected]
 CEF Survey tonight !!
 Homework 7 Status
 Homework 8 Due Today
 Remaining Lab Exercises Due Today
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
3
Summary of Last Session
 Web pages = text files with .HTML extension
 Use PFE to create/update pages/files
 Use IE (or other browser) to render/view pages
 Content/text versus tags
 HTML tags : <foo …> or <bar …> … </bar>
–
–
–
–
–
–
Structure of HTML page
Formatting
Lists of data
Links to other pages
Images
… much much more
 Lab Exercise – make three linked pages
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
4
Outline of Chapter 10
 Use Your Imagination
 Virtual Environments for Computing
 Hardware Pragmatics
 Operating Systems and Services
 Time Sharing in Action
 Files
 Contentions for Memory
 Summary
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
5
Use Your Imagination
 How would YOU like to interact with a
computer?
– Probably not at the hardware component level (AND, OR,
XOR, small circuits, etc.) – too low level
– Probably not at the PASCAL level, either – complex
programs and too detailed
 The way you would like to deal with a
computer system is called ‘a virtual
environment’
 Tonight we study some aspects of how you
can and do interact with a computer
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
6
Virtual Environments for Computing
 Look at typical things to do with your
computer: (I.e. what the ‘virtual environment’
lets you do)
 Logging In – to get access to many things:
 Requesting an application/function/program
 Manipulation of Files
 Calling System Functions/Programs
 Editing Files
 File Management
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
7
Hardware Pragmatics
 CPU/Memory
– CPU - the brains and coordinator of activities within the
computer
– Memory - bunch of bits - with addresses - data and
instructions (programs)
 Storage
– When not in memory, programs and data are stored on
other devices - e.g. disks (floppy and hard), CD ROMS
and other storage devices
 Other Computer I/O Devices
– Some input devices - scanners, mice, modem,
– Some output devices - printers, monitors, modem,
speakers ...
Storage
04/24/2003
CPU
Memory
I/O
Devices
}
CSCI 150:Introduction to Computer Science - Session 25
Computer
Hardware
Components
8
Operating Systems and Services
 The Operating system is a PROGRAM –
powerful, specialized and capable, but just
another program!
 Separates/mediates between users and
hardware!
 Layering model - will evolve over next few
slides
 4 major services provided by the OS
Access to computing functions
File system
Security
Time sharing aka
resource sharing
Storage
04/24/2003
CPU
CSCI 150:Introduction to Computer Science - Session 25
Memory
I/O
Devices
9
Hardware layer
–
–
–
–
Access to computing functions
Systems
programs
layer
Mail program, editors, compilers
Storage
CPU
Memory
I/O
Devices
 All just PROGRAMS!!!
 Operating System (OS) is able to
–
–
–
–
–
04/24/2003
identify the program by name
locate it on disk
find available computer memory
load program into memory
start it running - with params?
all on your behalf!
CSCI 150:Introduction to Computer Science - Session 25
10
Hardware layer
 Editors
 Mail Programs
 Compilers
…
File System
created
edited
saved
reloaded
deleted
moved
04/24/2003
Mail program, editors,
compilers
Storage
CPU
Memory
I/O
Devices
Hardware layer
–
–
–
–
–
–
File
System
Systems
programs
layer
 To organize and
manage information
stored in files typically stored on disks
but other devices too!
 Used by users directly
or by programs
 Files can be
More later on the structure of
storing files and getting access
to them - I.e. directories aka folders
Information takes all forms - ascii text files, word
processing files, databases, spreadsheets, programs (source files
and executables), even directories, initialization files,
data files, the windows ‘registry’ ...
CSCI 150:Introduction to Computer Science - Session 25
11
Security
3 kinds of security within computer system
1) Computing resources protection
logging in as a valid user
2) Internal file and function protections
who has access to which programs, files
and how
3) Protection from hardware failure
how to protect in case a disk fails
In general protection between you and the system …
Now what about OTHERS on your system?
Multi user!
Or Multi process!
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
12
Time Sharing
 Consider CPU utilization while you are sitting
at your computer!
 Is the computer ‘doing’ anything?
 Is the computer ‘doing’ anything ‘useful’?
 Could we set up the system so that it IS doing
something useful even if YOU aren’t?
 That is the main motivation behind Time
Sharing!
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
13
Time Sharing (continued) …
 A little history
– Computers used to be REAL expensive before there
were ‘personal’ computers - ‘glass rooms’
– Too expensive for individuals to own
– Only way to give computer/computing access to
individuals
» use (hardware) terminals to connect to a main
computer (mainframe or minicomputer)
» allow many users to each use a part or a share of
the computer at a time - e.g. timeshare the
computer resource
 How to implement this concept of ‘sharing the
computer as a resource’??
– The Process - within the computer
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
14
Time Sharing (continued) … aka
The Process
 The Process
– any “program in some state of execution in the
computer”
– various ‘states of execution’ for any process
» running and doing actual work
» waiting for input from the user (e.g. readln)
» awaiting completion of some output (e.g writeln)
» stopped/paused by the operating system (for
whatever reason!)
» awaiting external inputs (e.g. modem or CD ROM)
» awaiting completion of operating system services:
•
•
•
•
04/24/2003
loading program into memory
servicing a hardware device(modem, mouse, CD ROM)
accessing files
providing additional memory while program is running
CSCI 150:Introduction to Computer Science - Session 25
15
The Interrupt
 Processes execute until they are stopped or
paused or halted in some way
 Typically the reason for execution of the
current process to stop is the interrupt
 Several sources of interrupts
hardware
– external device - a printer or a modem
– computer itself - error condition (divide by zero) or even
a clock interrupt - remember clocks from digital design?
– OS - to allow other process(es) to get some
software
computation time - ‘share CPU time’
 What happens at interrupt?
–
–
–
–
04/24/2003
OS takes over to store all info about executing process
allows it to be restarted up again later
saves state of registers and memory allocated etc.
selects and starts (or restarts) another process!
CSCI 150:Introduction to Computer Science - Session 25
16
The OS and Processes
 A main job of the OS is to keep track of MANY
PROCESSES within the computer at any one
time
 Keep track of state of registers, memory
allocation, ‘state of execution’, etc.
 Goal: to optimize the overall resources of the
computer
 Major OS scheduling algorithm
– choose a process to run (complex algorithm here!)
» execute process until an interrupt occurs
» choose a process to run (might be the original one!)
 Not so much required on a PC but still applies!
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
Looks like
CPU
Execution
Cycle?
Spy??
17
Final OS Layering Diagram
Time
sharing
layer
User 1
User 2
File System
CPU
Memory
I/O
Devices
Hardware layer
Security
Perimeter
Storage
...
Systems
programs
layer
Mail program, editors,
compilers
User 3
Ultimately, the operating system is a (complex!) computer program whose sole responsibility is
to manage the resources of a computer system to optimize their usage on behalf of several users.
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
18
Time Sharing in Action
 Examples
– Book heavily based in command line style of computer
operations
– start a program - runs in the ‘foreground’
– can put it in the ‘background’ (different process state)
while starting another program in the ‘foreground’
 In Windows?
– Look at Task Bar = programs loaded AND running!
– Run TASKMAN - shows much the same information
– Example from Task Manager of Windows NT - see
bitmap image
– Multiple executing processes - multiple DOS windows!!
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
19
Windows Task Manager Display
Info about a Process/Task:
Process Name
Process ID
% CPU time being used
CPU time used
Memory Allocated
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
20
Files - Organization and Management
 Directory
– organized way of keeping track of files
– through naming and within a list - a directory of files
– in Windows aka folder
 Trees
–
–
–
–
–
too many files to store all in ONE directory
could have just a named set of directories
or could have subtrees - I.e. folders within folders
natural organizational principle - recursive descent
most OS’s also let you link a file from one folder into
another folder - a form of file sharing
– let’s look at directory/folder tree hierarchies - using
windows explorer
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
21
Directory/Folder Example
Folder
Hierarchy
(nested)
Selected
folder
04/24/2003
Files within
a folder
CSCI 150:Introduction to Computer Science - Session 25
22
Contention for Memory
 Ultimately memory becomes the issue in most
modern computers
Program 1
 OS needs to allocate use of the memory to provide
best balance between needs of programs
 Memory used both for programs and data
 Programs could all be loaded into memory, but also
could be loaded in smaller chunks or pages and OS
manages which pages are in memory at any given
time – through page fault (interrupts)
 So it can appear that many programs running in much
smaller memory than thought possible multiprogramming!
Program 2
Data 1
Data 2
Program 3
Don’t need
all of
program in
memory at
same time?
Program 3
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
23
Summary
 “Virtual Environments” - also known as ...
 Operating Systems - a computer program to
manage computer resources
–
–
–
–
access to system resources (hardware and programs)
file systems
security
time sharing/processes through interrupts
 Operating System manages resources through
process control, via interrupt responses as
well as memory management
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
24
Next Session
 Tuesday – April 29 – Last Lecture !!!
 Chapter 11 - Computer Communications also known as Networking Computers!
04/24/2003
CSCI 150:Introduction to Computer Science - Session 25
25