/
Chapter 10: Operating Systems Chapter 10: Operating Systems

Chapter 10: Operating Systems - PowerPoint Presentation

jane-oiler
jane-oiler . @jane-oiler
Follow
398 views
Uploaded On 2016-03-06

Chapter 10: Operating Systems - PPT Presentation

Chapter 10 Operating Systems Page 110 An operating system is a set of programs through which a computer manages its resources Its main functions are to Manage the computer hardware CPU performance amp utilization ID: 244071

program chapter file computer chapter program computer file process systemspage files systems graphics system access applicationspage time 14simulation database

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Chapter 10: Operating Systems" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Chapter 10: Operating Systems

Chapter 10Operating SystemsPage 110

An operating system is a set of programs through which a computer manages its resources.

Its main functions are to:

Manage the computer hardwareCPU performance & utilizationMemory allocation & protectionInput-output managementKeyboard controlMouse device driverPrinter spoolingDisplay monitorSlide2

Chapter 10

Operating SystemsPage 1112) Support application software

Word processors

Electronic spreadsheets

Computer graphics & gamesDatabase managementSlide3

Chapter 10

Operating SystemsPage 1123) Establish a user interface

Textual, with a command-line prompt

Graphical, with windows, menus, and iconsSlide4

Chapter 10

Operating SystemsPage 113Different Approaches to Processing

Batch Processing

Non-interactive execution of one or more programs with distinct input and output sessions

Time-SharingMultiple programs executing “simultaneously” (via time slices) on a single computer (either many users on a server or one user “multitasking”)Interactive ProcessingExecution of a program with additional input from the user and output to the user during executionMultiprocessing

Multiple CPUs available within the computer system, either across a network or within a single machine (e.g., a supercomputer)

RAM

Process

Process

Process

PCB

PCB

PCB

CPUSlide5

Chapter 10

Operating SystemsPage 114Memory Management

The

operating system

must coordinate the use of main memory for any active program on the computer.When the program is compiled, fake “virtual” addresses are used as placeholders for the memory addresses of data (i.e., variables) and instructions (i.e., functions, loops, and conditionals).When the program is loaded into RAM, the virtual “logical” addresses are mapped to actual “physical” addresses where the various parts of the program are really stored.Slide6

Chapter 10

Operating SystemsPage 115Paging

Since multiple programs might be active simultaneously and since RAM has a limited capacity, large segments of one program’s memory might be relegated to a backup device to make room for another program’s memory needs.

Program A’s Virtual Space

1

2

3

4

Program B’s Virtual Space

1

2

3

RAM

4

1

5

1

2

3

7

4

2

3

2

Backup Storage (Disk)

7

1

3

5

6

6

4

1

2

6

1

4

1

3

2

3

2

2

1

1

3

4

3

5

8

4

1

4

3

1

2

3

In this example, when program B is activated, space in RAM is made available by first “paging out” part of program A...

...and then “paging in” program B.Slide7

CPU Management

Every process executed by the CPU is managed by the operating system.New Process

(In a file on the hard drive, it needs to be loaded into RAM)

Ready Process(Loaded into RAM, it will run when allotted CPU time)

Waiting Process(Needs I/O or some event in memory, temporarily can’t run)Terminated Process(Finished executing, its memory must be marked “free”)Running Process(In RAM, with CPU processing its instructions)

OS “admits” process by loading into RAM

OS “dispatches” process by allotting CPU time

OS “interrupts” process to give another process CPU time

OS moves process to waiting state when it starts idling

OS moves process to ready state when it’s ready to resume

OS starts cleaning up after the process has completed

Conceptually, the operating system moves the process from state to state in its journey through CPU execution.Slide8

CPU Scheduling

When multiple processes are vying for the CPU’s attention, the operating system must schedule them.Common Scheduling Options:

First-Come First-Served (FCFS)

Disadvantage: Smaller jobs may have to wait an inordinate amount of time.

Shortest Job First (SJF)Disadvantage: Large jobs must wait until everything else is finished before starting.Round RobinDisadvantage: Processes constantly interrupted when time slices expire.Slide9

Chapter 10

Operating SystemsPage 118Resource Allocation Problems

Producer

Consumer

Waiting

Full Queue

Producer

Consumer

Waiting

Empty Queue

Mutual Exclusion

If two processes require access to the same

nonshareable

resource at the same time, then both cannot be accommodated.

Example: Producer & Consumer

When extreme cases occur (either there are no resources available to be consumed, or no room for more to be produced), a “semaphore” is set to signal that someone must wait.

Deadlock

If two processes are simultaneously blocking each other’s progress, then neither one may be able to proceed.

One process copies from the

flash

to the

DVD

One process copies from the

DVD

to the

flashSlide10

Chapter 11: File Systems and Directories

Chapter 11File Systems and DirectoriesPage 119

Data is stored on magnetic and optical disks in

files, named collections which are, in turn, grouped together into

directories.

To distinguish the types of data being stored in different files, the names of files are suffixed with an identifying file

extension

.Slide11

File Access

Chapter 11File Systems and DirectoriesPage 120

There are two major ways in which files are organized and accessed.

Sequential Access

The records in the file are organized as a list and are retrieved and processed one at a time from the beginning to the end of the file.Direct AccessThe records in the file are arranged so an individual record may be retrieved without examining other records in the file.Slide12

Sequential File Access

Chapter 11File Systems and DirectoriesPage 121

With

sequential access, records are retrieved by starting at the beginning of the file and extracting them in the order in which they exist within the file.

An example of this is the common input file (cin) in C++, which uses the input operator (>>) to access the next available piece of keyboard-generated data.AdvantagesEasy

to program

Allows

simple file structures

Well

suited to many common programming applications (pattern searches, small files, rarely processed files)

Disadvantage

Poor

access performance

Common

Application:

Text FilesSlide13

Indexed Files

Chapter 11File Systems and DirectoriesPage 122

To implement direct access in file organization, an indexed directory is often stored in memory.

This directory is basically a table consisting of some aspect of each record (called a

key) and the corresponding record’s location within the file.NameSector

Track

Adams

5

68

Bosley

4

27

Carter

5

43

SSN

Sector

Track

402231161

5

43

627880013

3

71

759307562

4

11Slide14

Hashed Files

Chapter 11File Systems and DirectoriesPage 123

To provide direct access to the records in a file without the overhead of an indexed directory,

hashing is a viable alternative.

With hashing, one of the record’s key fields is used to map the record to a particular section (or “bucket”) in the memory device.If the hashing function is strategically chosen, then the buckets will be relatively balanced and efficiency will be enhanced.Fairly Good Hashing Function:Last digit of SID

0

2

1

2

2

2

3

2

4

3

5

2

6

2

7

3

8

2

9

6Slide15

Directories

Chapter 11File Systems and DirectoriesPage 124

To organize files within a computer system, hierarchical directories are usually implemented.

This traditional approach to file organization is known as the “folder metaphor” since it is analogous to the organization of paper file folders.Slide16

Disk Scheduling

Chapter 11File Systems and DirectoriesPage 125

Accessing secondary memory is one of the most time-consuming aspects of processing, so a primary goal is to ensure that such access is handled as efficiently as possible.

The most common approach is to have the read-write heads move towards the shaft, reading all requested sectors of all requested tracks as each successive cylinder is reached.

Once the shaft is reached, the read-write heads move away from the shaft, reading all requested sector/track combinations until the outer platter edge is reached, whereupon the entire process is repeated.Slide17

Chapter 12: Information Systems

Chapter 12Information SystemsPage 126

Information systems are software applications that facilitate the organization and analysis of data.

Example: Spreadsheet software allows users to place raw data in tables and then utilize formulas and basic graphical mechanisms to generate calculations and illustrations from it.Slide18

Database Structures

Chapter 12Information SystemsPage 127

An alternative to a distributed information system based upon files is a centralized system based upon the concept of

databases.

File-OrientedSystemDatabase-OrientedSystemVideo Rental Files

Rental Dept.

Video

Sales

Files

Sales Dept.

Video Purchase Files

Purch-asing

Dept.

Advertise-

ment

Files

Market-

ing

Dept.

Store Upkeep Files

Maint-enance

Dept.

Store Personnel Files

Payroll Dept.

Rental Dept.

Sales Dept.

Purch-asing Dept.

Market-ing Dept.

Integrated Database

Maint-enance Dept.

Payroll Dept.

DISADVANTAGES OF EACH SYSTEM

File-Oriented

Database-Oriented

Duplication of effort

Data security problems

Multiple error sources

Widespread error effectsSlide19

A Modular View of a Database System

Chapter 12Information SystemsPage 128

The DBMS uses

schema

and subschema to ensure data security.A schema describes the way the entire database is organized.A subschema describes the organization of the portion of the database that is accessible to a particular type of user.Slide20

The Relational Database Model

Chapter 12Information SystemsPage 129

The simplest conceptual arrangement of a database uses a table of rows (called

tuples) and columns (called

attributes).Last NameFirst NameM.I.

SID

Hrs

Class

GPA

Major

DOB

Image

Moose

Bullwinkle

J

900626977

112

Sr

3.24

CHEM

03/21/76

Bear

Yogi

D

900129875

48

So

2.17

BIOL

02/16/79

Coyote

Wile

E

900705548

54

So

3.16

MATH

11/05/81

Hound

Huckleberry

H

900339227

75

Jr

3.05

MKTG

09/12/83

Gorilla

Magilla

B

900187014

102

Sr

3.76

ELED

12/12/80

Pig

Porky

P

900882635

66

Jr

2.38

ECON

05/02/82

The major advantage of this model is its logical conceptualization.

The major disadvantage is the substantial amount of software and hardware overhead required to maintain and access the table.Slide21

Relational Operator SELECT

Chapter 12Information SystemsPage 130

The SELECT operation determines which

tuples have particular attributes.

ORIGINAL TABLECode

Description

Price

213345

9v Battery

1.92

311452

Power Drill

34.99

254467

60W Bulb

1.47

309772

Mini-Ratchet Set

6.50

256568

Halogen Light

12.99

290031

Flat Screwdriver

8.45

NEW TABLE

Code

Description

Price

213345

9v Battery

1.92

254467

60W Bulb

1.47

309772

Mini-Ratchet Set

6.50

290031

Flat Screwdriver

8.45

Apply SELECT with

Price < 10.00Slide22

Relational Operator PROJECT

Chapter 12Information SystemsPage 131

The

PROJECT operation limits the scope of the database to specific attributes.

ORIGINAL TABLECode

Description

Price

213345

9v Battery

1.92

311452

Power Drill

34.99

254467

60W Bulb

1.47

309772

Mini-Ratchet Set

6.50

256568

Halogen Light

12.99

290031

Flat Screwdriver

8.45

NEW TABLE

Code

Price

213345

1.92

311452

34.99

254467

1.47

309772

6.50

256568

12.99

290031

8.45

Apply

PROJECT

with

Code & PriceSlide23

Relational Operator JOIN

Chapter 12Information SystemsPage 132

The

JOIN operation combines multiple tables that have common attributes.

Table CUSTOMERCusNo

CusName

CusZip

RepNo

1132445

Walker

62449

231

1321242

Rodriguez

62025

125

1657399

Vanloo

62363

231

1312243

Rakowski

62294

167

1542311

Smithson

62025

421

1217782

Adares

62650

125

NEW TABLE

CusNo

CusName

CusZip

RepNo

RepPhone

1132445

Walker

62449

231

6182431124

1321242

Rodriguez

62025

125

6182439887

1657399

Vanloo

62363

231

6182431124

1312243

Rakowski

62294

167

6183426778

1217782

Adares

62650

125

6182439887

Apply

JOIN with

CUSTOMER.RepNo

=

SALESREP.RepID

Table SALESREP

RepID

RepPhone

125

6182439887

167

6183426778

231

6182431124

333

3145267759Slide24

Concurrency Control

Chapter 12Information SystemsPage 133

A potential problem with database systems that allow multiple access points is the loss of data integrity.

At ATM #1: Deposit $400

At ATM #2: Withdraw $200Get Balance...

$500

Get Balance...

$500

Add $400 to Balance...

$900

Subtract $200 from Balance...

$300

Store new Balance...

$900

Store new Balance...

$300

Either balance that’s stored would be incorrect, since the correct balance is

$700

!Slide25

Databases and Privacy

Chapter 12Information SystemsPage 134

The proliferation of information on database systems poses a potential threat to the privacy of people about whom the data refers.

Example: Medical Databases

Advantages:Reduction of paperworkFewer false insurance claimsFacilitates disease trackingImmediate access in emergencyCost-effective

ID of treatment

Safer

than paper records

Disadvantages:

Employer

access might cost jobs

High risk” insurance increases

Unsolicited

advertisements

Fear

inhibits candid disclosure

Inaccuracies

are spread easily

Dr

./patient confidentiality lossSlide26

Cryptography

Chapter 12Information SystemsPage 135

Networks are set up to send messages right past stations that aren’t authorized to read them, but what’s to

prevent

such unauthorized viewing?The most common solution to this problem is encryption, where the message is coded in such a way that only the receiving station can decode it.

Message

MessageSlide27

Public-Key Encryption

Chapter 12Information SystemsPage 136

1.

Create Message

I have affixed to me the dirt and dust of countless ages!Chuck mdbriugndlwgLinus

mamnsgfyddkd

Lucy

qhgwdnchsgsh

Patty

ahwbsgcydhzx

2.

Look Up Recipient’s Public Key

3.

Encrypt Message With Recipient’s Public Key

xsjb2dhdkWb$xzduYdm!dj5slLssghd8nd&hsnqabi?dsjsg%

4.

Transmit Encrypted Message

xsjb2dhdkWb$xzduYdm!dj5slLssghd8nd&hsnqabi?dsjsg%

5.

Decrypt Message With Recipient’s Private Key

I have affixed to me the dirt and dust of countless ages!Slide28

Key-Based Authentication

Chapter 12Information SystemsPage 137

When a message is received, how can you be sure who it came from?

1.

Create MessageI’m going to recruit that funny-looking kid who plays shortstop on Chuck’s team!2.Encrypt Message With Sender’s Private Key

Ma3ndhvyr#bcjaqwpfQkguiorkfohskxi8vce%fpgkjfhikfvdamxxyemfideychssfhsgdhahdm$dlglyn7buchso

3.

Transmit Encrypted Message

Ma3ndhvyr#bcjaqwpfQkguiorkfohskxi8vce%fpgkjfhikfvdamxxyemfideychssfhsgdhahdm$dlglyn7buchso

4.

Decrypt Message With Sender’s Public Key

I’m going to recruit that funny-looking kid who plays shortstop on Chuck’s team!Slide29

Chapter 13: Artificial Intelligence

Chapter 13Artificial IntelligencePage 138

Computations

that make it possible for a machine to perceive, reason, and act in a manner consistent with human behavior form the field known as

artificial intelligence.The Turing TestA human questioner inputs questions and guesses which respondent is human, based on the answers given.

If the questioner cannot tell

which respondent is human,

the software passes the test.Slide30

Computer Reasoning

Chapter 13Artificial IntelligencePage 139

To simulate logical reasoning,

heuristic functions are often used.

A heuristic is an artificial measure of how close the computer’s current status is to its problem-solving goal.In the tic-tac-toe example above, when the computer is ready to make an X-move, it uses the heuristic max{F(config), where config can be the result of any O-move}.

F

(

config

) =

(# of

completable

rows, columns, and diagonals for X-player) – (# of

completable

rows, columns, and diagonals for O-player)

if

config

is a non-winning configuration

if

config

is an X-win

-

if

config

is an O-win

O

O

X

X

X

O

O

X

X

X

O

O

O

X

X

X

O

O

X

X

O

X

O

O

X

X

O

X

O

O

X

O

X

2-1=1

3-1=2

2-1=1

3-1=2

O

O

X

X

X

O

O

O

X

X

X

O

O

X

X

X

O

O

O

X

X

X

O

O

O

X

X

O

X

-

3-2=1

2-2=0

3-2=1

O

O

X

X

X

O

O

O

X

X

X

O

O

O

X

X

X

O

O

X

X

X

O

O

O

X

O

X

X

-

2-2=0

2-2=0

3-2=1

O

O

X

X

X

O

O

O

X

X

X

O

O

O

X

X

X

O

O

X

X

X

O

O

O

X

X

X

O

-

2-1=1

2-1=1

2-1=1

O

O

X

X

X

O

O

O

X

X

X

O

O

O

X

X

X

O

O

X

X

O

X

O

O

X

O

X

X

-

2-1=1

3-1=2

3-1=2

1

-

-

-

-

Slide31

Expert Systems

Chapter 13Artificial IntelligencePage 140

By programming a computer with the assistance of experts in a particular field, an

expert system can be developed to perform very specialized tasks.

Users in need of expert assistance complete on-line questionnaires and the expert system analyzes their responses and assigns probabilities to various diagnoses.Slide32

Genetic Algorithms

When a problem has no definitive algorithmic solution, it’s possible that a technique can be developed by which the solution can evolve.

This type of solution, known as a genetic algorithm, involves the generation of numerous possible solutions called a

population. Each member of the population has a

fitness score based on the goal of the problem. Subsequent generations are then created by blending members of the population and subjecting some to mutations. The goal is to “breed” solutions, over multiple generations, that better solve the problem.For example, in the example at left, the problem of producing a flywheel composed of a variety of ceramic, polymer, and fiber materials is addressed.An optimal balance of materials is desired so the flywheel can spin faster (thus producing greater kinetic energy), but not so fast that the resulting shear forces will rip the flywheel apart.

Chapter 13

Artificial Intelligence

Page

141Slide33

Neural Networks

Chapter 13Artificial IntelligencePage 142

To simulate learning, certain multiprocessor systems, called

neural networks, have been built to “learn” to recognize particular patterns as correct or incorrect, based upon a trial-and-error process.

In the example below, a neural network is used to teach a computerized system how to back a truck up to a loading dock.The physical characteristics of the truck are programmed, with the relationship between the steering wheel, the tires, the cab, and the trailer formally calculated.Starting at some initial position, the truck is backed up one meter at a time, with programmed steering; the error in the result is measured and factored into the next attempt, until the error is zero.Slide34

Natural Language Processing

Chapter 13Artificial IntelligencePage 143

Written Comprehension: How can a computer be programmed to grasp the syntax and semantics of a natural language?

John saw the boy in the park with the telescope.

Question: Whose telescope is it?Answer: John’sJohn saw the boy in the park with the puppy.

Question: Whose puppy is it?

Answer: The boy’s

John saw the boy in the park with the statue.

Question: Whose statue is it?

Answer: The park’sSlide35

Speech Recognition

Chapter 13Artificial IntelligencePage 144

0011010101000010111110101001001101010100101011110010101101010011010101010101010101010101001

1. The PC sound card converts analog sound waves spoken into a microphone into a digital format.

2. A software acoustical model breaks the word into phonemes.

0011010101000

“K”

0101111101010

“AH”

0100110101010

“M”

0101011110010

“P”

1011010100110

“Y”

1010101010101

“OO”

0101010101001

“T”

3. A software language model compares the phonemes to words in its dictionary.

“K”

“AH”

“M”

“P”

“Y”

“OO”

“T”

CA

LM

COM

MA

COMP

ARE

COMP

E

TE

COMP

LE

TE

COMPUTE

4. Once the software decides on the most likely candidate, it displays that word.

COMPUTESlide36

Robotics

Chapter 13Artificial IntelligencePage 145

Robots are programmable devices capable of manipulating objects and performing tasks much like humans are able to do.

One of the more difficult problems when programming a robot is determining when it is about to collide with something, when it has collided with something, and what to do in response to a collision.

Collision AvoidanceUse scanners to determine the robot’s proximity to other objects, redirecting the robot when a collision is imminent.Collision DetectionUse sensors at strategically located places on the robot to determine if a collision occurs.

Collision Reaction

Go around?

Climb over?

Bounce back?

Run away?

Drop dead?Slide37

Robot Challenges

Chapter 13Artificial IntelligencePage 146

Other common human actions that are difficult to program include propelled locomotion and manual manipulation.

Walking Gait

How can a robot be programmed to propel itself forward on “legs” and still maintain its balance?GraspingHow can a robot be programmed to grasp part of a stack of objects, without toppling the rest of the stack?Slide38

AI in Games

Chapter 13Artificial IntelligencePage 147

Non-player characters in games need to appear intelligent, even though they are controlled by the game program instead of by a game player.

Flocking

By providing a group of characters with simple goals and behaviors, a “mob mentality” can be implemented with a minimum of code.Dead ReckoningBy having a game-driven predator character react to the anticipated position of its player-driven prey (using the prey’s current position and velocity), a chase can appear more realistic.Slide39

Chapter 14: Simulation, Graphics, and Other Applications

Chapter 14Simulation, Graphics, and Other ApplicationsPage 148

In order to gain insight into complex systems, scientists often build computer models to simulate their performance.

Continuous Dynamic Simulation

Elaborate equations representing the different aspects of the model are periodically solved to generate a sequence of snapshots of its performance (e.g., flight simulators).Discrete Event SimulationThe system is represented as a chronological sequence of events, each of which subtly impacts the overall state of the system (e.g., network modeling).Slide40

Computer Graphics

Chapter 14Simulation, Graphics, and Other ApplicationsPage 149

Recent advances in processor power, display technology, memory capacity, and rendering algorithms have made it possible to produce dazzling images using relatively inexpensive computers.Slide41

Drawing Lines and Circles

Chapter 14Simulation, Graphics, and Other ApplicationsPage 150

Pixel-based display technologies cause inherent problems when displaying circles or non-vertical/non-horizontal lines.Slide42

Antialiasing

Chapter 14Simulation, Graphics, and Other ApplicationsPage 151

Complex scenes lose their integrity when using single-colored pixels.

Jagged Profiles

Loss Of DetailDisintegrating Textures

A common way to address this problem is with

antialiasing

algorithms, which combine the colors affecting a particular pixel into a “blended” color that will minimize these negative effects.Slide43

3D Shading

Chapter 14Simulation, Graphics, and Other ApplicationsPage 152

The easiest way to store information about most 3D objects is as a set of polygons.

Unfortunately, smooth objects aren’t necessarily polyhedral, so the resulting image looks bad.

The common solution to this problem is to use a shading algorithm, which progressively blends the shading of adjacent polygons to smooth out the reflection of the virtual light across the surface.Slide44

Lighting Effects

Chapter 14Simulation, Graphics, and Other ApplicationsPage 153

In order to accurately model lighting effects, the shading algorithm must take into account the position of the graphical scene’s virtual light source and the rendered objects’ locations with respect to it.

More sophisticated lighting models take into account

radiosity, the fact that light reflects off the surface of some objects and, in turn, illuminates other objects.Slide45

Ray Tracing

Chapter 14Simulation, Graphics, and Other ApplicationsPage 154

Rays are cast from the viewer’s position through each pixel; the first object that’s hit is the one that’s rendered in that pixel.

To calculate shadows, the ray is bounced from the hit object to the scene’s light source, if another object is hit on the way to the light, then the original object is in shadow.

To calculate reflections, the ray is bounced from the hit object (if it’s shiny) at the opposite angle at which it hit the object; if another object is hit, then the second object will be reflected on the surface of the first object.Slide46

Texture Mapping

Chapter 14Simulation, Graphics, and Other ApplicationsPage 155

To give a greater sense of realism to 3D graphical objects,

texture mapping

provides an inexpensive means of placing 2D “wallpaper” around the objects.Bump mapping can make the results even more visually striking, by adding a displacement factor across the surface of the objects, giving the illusion of 3D texture in the resulting lighting effects.Slide47

Character Animation

Chapter 14Simulation, Graphics, and Other ApplicationsPage 156

By strategically manipulating specific vertices comprising an animated model, a graphics artist can make the model behave in a lifelike manner.Slide48

Embedded Systems

Chapter 14Simulation, Graphics, and Other ApplicationsPage 157

Special-purpose computer systems are often designed to perform a specific list of dedicated tasks.

Embedded systems:

are often built into the devices they control, rather than being separate devices.frequently have real-time performance constraints.often have low performance requirements, allowing cheaper hardware to be used.use software called firmware, usually stored in ROM or flash memory.Slide49

Electronic Commerce

Chapter 14Simulation, Graphics, and Other ApplicationsPage

158

As networking capabilities have become ubiquitous, the ability to conduct financial business electronically has soared.Slide50

Computer Security

Chapter 14Simulation, Graphics, and Other ApplicationsPage 159

A computer virus piggybacks on another file to “infect” a system.

When a user runs an infected program, the computer starts by copying the program from the disk, where it is stored and inactive, into RAM, where it can be executed.

The viral code begins running first, while the infected program is still quiescent.

The virus copies itself in a part of RAM separate from the program so that it can continue its work even after the user starts running other software.

Its initial work done, the virus passes control back to the infected program.

When the user runs a different program, the dormant virus begins running again.

It inserts a copy of itself into the previously uninfected software so that the cycle of virulence can repeat.Slide51

Worms and Trojan Horses

Chapter 14Simulation, Graphics, and Other ApplicationsPage 160

Worms

are parasitic computer programs that replicate, but unlike viruses, do not infect other computer program files.

Worms can create copies on the same computer, or can send the copies to other computers via a network.Worms often spread via e-mail or chat applications. A Trojan horse is a malicious program that pretends to be a benign application.A Trojan horse program purposefully does something the user does not expect.Trojan horses are not viruses since they do not replicate, but they can be just as destructive.One type of Trojan horse, known as a

logic bomb

, is set to execute whenever a specific event occurs (e.g., a change in a file, a particular series of keystrokes, a specific time or date).Slide52

Fighting Viruses

Chapter 14Simulation, Graphics, and Other ApplicationsPage 161

Various techniques have been developed to combat computer viruses.

Generic Antiviral Program

Flags activities--such as the alteration of critical sites in RAM or particular files on disk--that are likely to arise from a virus in action. Preventing these illicit acts will not eliminate the virus but can stop it from infecting additional programs or interfering with the computer's normal operation. Signature ScannerSearches a user's disks looking for fragments of program code that appear in known viruses. Antiviral SnapshotsCapture mathematical "fingerprints" of crucial programs and data. Subsequent changes strongly suggest viral infection. Advanced algorithms can use the original fingerprints to recover a pristine program from the virus-altered version.