CS160 Exploring Computer Science - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

CS160 Exploring Computer Science

Description:

The stars made no answer. -- Rabindranath Tagore, 'Stray Birds' Review of Chapters 3 & 4 ... 10 cookies. 50 grams of sugar. 3 slices of cake. etc. Values. Variable ... – PowerPoint PPT presentation

Number of Views:231
Avg rating:3.0/5.0
Slides: 57
Provided by: Preu
Category:

less

Transcript and Presenter's Notes

Title: CS160 Exploring Computer Science


1
CS160 Exploring Computer Science
Review of Chapters 3 4
  • "The learned say that your lights will one day be
    no more." said the firefly to the stars. The
    stars made no answer.
  • -- Rabindranath Tagore, "Stray Birds"

2
Chapter 3 Operating Systems and Networks
  • OS
  • Application System Software
  • OS Components and Functions
  • Key OS terminology
  • Bootstrapping, Virtual Memory
  • OS Process Administration in Time-share mode
  • Handling competition among processes
  • Communicating with other devices (Device
    Controllers)

3
Software Classification
  • Software
  • Applications System
  • MS-Excel
  • Quake II Utility Operating System
  • WordPerfect Windows
  • Linux
  • Solaris
  • Shell Kernel

4
Application and System Software
  • Application Software
  • User needs
  • System Model
  • Source Code
  • Machine instructions
  • Programs to help USER perform tasks that utilize
    the machines capabilities
  • System Software
  • Machines needs
  • Services
  • Hardware management
  • Machine instructions
  • Programs that help the MACHINE perform tasks that
    manage the machines functions

5
User environments
  • Single-tasking vs. Multi-tasking
  • Single-user vs. Multi-user
  • Batch vs. Time-sharing
  • How can we accommodate such varied functionality?
  • Design a set of layered software that can
  • manage processes
  • manage users
  • manage resources
  • manage hardware
  • control overall working of the machine

6
Why Layered Software?
  • Why is OS designed as a layered software?
  • It breaks a larger problem to smaller, more
    manageable, subtasks
  • Each subtask can be implemented independently
  • A layer can be replaced with a different
    implementation without affecting other layers
  • Example Command layer can be upgraded or
    modified with a different implementation without
    affecting the Service layer functionality
  • Each layer considers the other layer as an
    abstract tool

7
Boot Strapping
  • ROM A portion of main memory is constructed such
    that information is permanently burned in and is
    known as Read-Only Memory
  • The start-up program for the machine resides in
    this ROM portion of memory which has the same
    cell address that CPU is hard-wired to look for
    when power is turned on
  • When CPU is turned on, it looks for this small
    program at its hard-wired cell address always,
    which happens to be the ROM portion of memory
    that always retains its contents and cannot be
    changed
  • The small program that is permanently stored in
    ROM is called the Bootstrap.
  • Bootstrap programs in PCs usually instruct the
    machine to load the OS from floppy first, and if
    it fails load it from hard-drive.

8
Bootstrapping Step1
9
Bootstrapping Step 2
10
Operating System Components
  • CPU Management
  • Process Management
  • Memory Management
  • File Management
  • I/O System Management
  • Interface to the User
  • Shells
  • Graphical User Interface
  • Persistent Storage Management
  • Distributed Systems and Networks

11
Functional Overview of Modern OS
12
Key OS Terminology
  • Kernel and Shell
  • Process and Program
  • Scheduler and Dispatcher
  • CPU Interval Timer and Time slices
  • Interrupt and Interrupt Handler
  • Process Administration
  • Interprocess Communication

13
Process Management
  • A process is a program in execution. A process
    needs certain resources, including CPU time,
    memory, files, and I/O devices, to accomplish its
    task.
  • The operating system is responsible for the
    following activities in connection with process
    management
  • Process creation and deletion
  • Process suspension and resumption
  • Provision of mechanisms for
  • Process synchronization
  • Process communication

14
Processes Administration Time-sharing
15
Handling competition among processes
  • Semaphores
  • Critical Region A set of instructions that can
    be executed by only one process at a time
  • Mutual Exclusion Requirement that only one
    process execute such Critical Region instructions
    at any time
  • How to implement Mutual Exclusion?
  • Use a Semaphore, as a single-instruction
    Test-and-Set flag
  • Check for the semaphore flag GO before entering
    the Critical Region set the flag to STOP as
    soon as you enter re-set the flag to GO when
    you exit.

16
Virtual memory
  • In a multi-user, multi-tasking environment, main
    memory space is limited and cannot accommodate
    all the programs
  • OS creates an illusion of larger memory
  • Memory manager divides the required space into
    pages and store these pages in the hard disk
  • As and when the next page is needed, memory
    manager will exchange the new page for the old
    one that is not needed anymore for program
    execution
  • Thus programs continue to execute as though there
    was no space crunch to begin with
  • Such an illusionary memory space is called
    Virtual Memory

17
Communicating with other devices
  • CPU and Main Memory together form the Core of a
    machine, which we will call the computer, or the
    processor
  • How does the computer communicate with other
    devices?
  • Through intermediary devices called Controllers

18
Device Controllers
  • Each device has its own controller by design
  • In modern PCs, the controllers plug into
    motherboard and connect via cables to their
    devices
  • Each controller if often a computer in its own
    right, with a CPU and memory circuitry
  • Controllers communicate with the processor via
    dedicated controller bus or system bus
  • Controllers pass messages and data between their
    respective devices and the processor by
    converting the messages and data into forms
    compatible with the main processor design

19
Pictorial View Device Controllers
CPU
Cache
Processor
Printer
Network Medium
Disk
Disk
DiskController
NetworkController
PrinterController
Main Memory
System Bus
CD-drive Controller
Modem Controller
CD-drive
Modem
20
Summary
  • OS is a system software designed to manage the
    various components of a computer system with
    kernel being its core and shell being its
    interface to the user
  • OS Kernel has several components like memory
    manager, i/o manager, file manager that perform
    the appropriate functions
  • Bootstrapping loads the OS into processor main
    memory at start-up
  • Process administration in time-share systems
    involve scheduler, dispatcher and interrupts set
    up by interval timer
  • Competing processes can be handled via Deadlock
    detection and avoidance, or Semaphores
  • Device Controllers handle communication between
    processor and other devices attached to the system

21
Chapter 3 Networks
  • Classification of Networks based on Topology,
    Ownership, Geography and Transmission Mode
  • Network Protocols The Internet
  • IP layers Application, Transport, Network, Link
  • TCP vs. UDP

22
Computer Network Fundamentals
  • A Computer Network is a
  • group of computers connected such that they allow
    for remote communication among themselves

23
Network Terminology
  • Node
  • anything connected to the network,
  • usually a computer, but it could be a printer or
    a scanner
  • Link
  • physical medium such as coax cable, fiber optic
    cable etc. connecting the machines
  • Segment
  • any portion of a network that is separated by a
    switch, bridge or a router from another part of a
    network.
  • Backbone
  • the main physical cabling connecting all the
    segments
  • holds and supports the physical network, just as
    the name suggests
  • Topology
  • The way each node is physically connected to the
    network

24
Network Classifications
  • Computer Networks are classified based on
  • Topology
  • The way in which they are physically connected
  • Ownership
  • Private (closed network), Public (Open network)
  • Geography
  • WAN, LAN, MAN
  • Transmission
  • Circuit switched, Packet Data, Asynchronous
    Transfer Mode (ATM), Frame Relay
  • For example A subset of PCC computers could be
    configured in a star topology with private LAN
    using Frame Relay mode of transmission

25
Main Network Classifications
  • Two main classifications we will look at are
  • Topology
  • Ring, Bus, Star, Tree, Mesh, Hybrid
  • Geography
  • LAN often machines hooked up within a building
  • WAN connects cities domestically and across the
    world

26
Connecting Networks Bridge
  • Two compatible network topologies can be directly
    connected using a Bridge to form a larger network

27
Connecting Networks Routers
  • Non-compatible networks are connected such that
    they form a network of networks, referred to as
    an internet, using a Router which knows how to
    handle each of the two connecting networks they
    remain independent and can communicate only via
    the Router.

28
The Internet
  • An internet is just an interconnection of two
    independent networks in two topologies
  • The Internet (with capital I) is a special
    network of networks involving LANs and WANS all
    over the world, connecting millions of machines,
    using specialized network protocols

29
Internet Topology
  • Many colleges and universities collaborated on
    research and set up their own indigenous
    internets leading to the establishment of
    conceptual domains
  • This led to haphazard growth making it necessary
    to standardize connections and addressing
  • Internet is a mish-mash of domains having Bus,
    Star, Mesh, some hybrid topology interconnected
    by gateway routers

30
Internet Domains
  • A domain is an autonomous system configured and
    controlled by its owner
  • Each domain has a name as well as an address
    which needs to be registered with ICANN
  • A newly registered domain can attach to the
    Internet via gateways
  • Gateways are essentially routers with certain
    special functionality

31
Network Protocols
  • Network Protocols are a collection of rules
    governing network activities to be followed by
    all computers in the network, such as
  • Data/Message format for sending and receiving
  • Addressing scheme to locate networks and machines
    in the network
  • Transmission format and privileges
  • Routing format and specifications
  • Because there is no centralized governing agency
    or board of directors or regents, protocols play
    a vital role in the smooth and efficient
    operation of networks

32
Common Network Protocols
  • Token Ring Protocol
  • For controlling transmission rights in a network
    configured in ring topology
  • Internet Protocol (IP)
  • For formatting, controlling, and regulating
    Internet traffic
  • File Transfer Protocol (FTP)
  • For controlling the transferring of files across
    the Internet
  • HyperText Transfer Protocol (HTTP)
  • For transferring hypertext (text, images, audio,
    video) across the Internet
  • Simple Mail Transfer Protocol (SMTP)
  • For transferring email across the Internet
  • Post Office Protocol (POP)
  • For accessing local mail server and transferring
    email

33
Internet Protocol IP
  • Each computer on the network is identified by a
    unique address, known as the IP address
  • Each message, be it text, image, or sound, is
    broken up into packets of about 1500 characters
    and transmitted packet-by-packet by the sender or
    source machine
  • Each packet has headers showing source IP
    address, destination IP address, and its Sequence
    Number
  • Headers help Routers or Hosts route the packets
    to the destination machine
  • Destination machines reassemble all the packets
    it receives using another set of rules, the
    Transmission Control protocol (TCP) that verifies
    if any packets got lost along the way

34
Name Resolution DNS
  • Humans dont like to deal with numbers a lot, so,
    we set up names that are easier to work with
  • TLD Top-level domains that we already know are
    .com, .edu, .org, .net, .gov
  • Domain names need to be registered with ICANN,
    that associates a name with an IP address for
    that domain.
  • Example pcc.edu
  • Individual machines within that domain can then
    have another identifying name
  • Example faculty.pcc.edu
  • DNS Domain Name Servers maintain a look-up table
    associating IP address with host names.

35
Internet Architecture
  • 4-Layered Architecture
  • Application
  • Transport
  • Network
  • Link
  • Study what each layer does.

36
TCP and UDP
  • TCP establishes connection with destination first
    before sending any packets
  • Reliable TCP works at both ends of the
    connection the sender end waits for
    acknowledgement from receiver end and retransmits
    any lost packets
  • Slightly slower and less efficient as a result of
    retransmission
  • UDP is connectionless just blindly sends the
    data even if the destination machine is not
    operational
  • Not Reliable Does not wait for acknowledgement
    and retransmit lost packets
  • More streamlined

37
Summary
  • Networks are a group of computers physically
    linked to share data and resources
  • Networks can be classified based on topology,
    geography, ownership, transmission
  • Network Protocols define how networks should
    handle data as there is no centralized
    controlling authority
  • The Internet is a special network of networks
  • 4-layered software architecture
  • Uses TCP/IP protocol suite for transmission of
    data
  • Special form of addressing, known as IP
    addressing

38
Chapter 4 Algorithms
  • Main components of an algorithm
  • Variables and values, Instructions, Sequences,
    Procedures, Selections, Repetitions,
    Documentation
  • Algorithm representation using Pseudocode
    notation
  • Algorithm Analysis

39
Algorithms Definition
  • An algorithm is an 1ordered set of 2unambiguous,
    3executable steps that define a 4terminating
    activity
  • Brookshear
  • The term Algorithm differs from terms like
    Method, or Technique as algorithm attempts to
    encode intelligence in some way.

40
Algorithms Definition
  • Ordered algorithms specify the sequencing of
    steps in a process
  • Unambiguous algorithms specify with clarity
    what activity or action should occur
  • Executable algorithms specify action that can,
    in fact, be done
  • Terminating there is a well-defined end point

41
Ambiguity
  • Ambiguity is inherent in the English Language
  • Understand the problem clearly and eliminate
    ambiguity when defining the problem
  • Computer Scientists have developed formal
    languages and methods to deal with ambiguity

42
Algorithm Discovery
  • How are algorithms found in the first place?
  • The Art of Problem Solving
  • Can the process of problem-solving be reduced to
    an algorithm itself?
  • This has been shown to be impossible
  • (See Chapter 11)
  • Ability to solve problems remains more of an
    artistic skill to be developed rather than a
    precise science to be learned

43
Getting a foot in the door
  • Working Backwards
  • Knowing what the output needs to be, work back up
    to the given input
  • Adapt an existing solution
  • Understand the solution to a related problem and
    apply it to the problem at hand
  • Stepwise Refinement
  • Decompose the given problem into several sub
    problems and solve them progressively, leading to
    refinement of solution

44
TD and BU Methodologies
  • Top Down Methodology
  • General to Specific
  • Example, Stepwise Refinement
  • Bottom Up Methodology
  • Specific to General
  • The two methodologies complement each other and
    are often used in conjunction.
  • TD Stepwise Refinement is usually guided by the
    problem solvers intuition, working in the BU
    mode.

45
Algorithm Representation
  • Before learning to code a program in any specific
    language, we will use a less formal notational
    system for writing algorithms viz., Pseudocode
  • Pseudocode
  • A Consistent,
  • concise notation for representing
  • recurring semantic structures,
  • which in turn will become the primitives for
    expressing future ideas.

46
Components of an Algorithm
  • Variables and values
  • Instructions
  • Sequences
  • Procedures
  • Selections
  • Repetitions
  • Documentation

47
Variables
  • Are containers for values places to store
    values
  • Example

48
Procedure
  • A named sequence of instructions
  • So that you can
  • Refer to it collectively (by name)
  • ...instead of individually (by each instruction
    in the sequence)
  • Example
  • Drive_To_PCC

49
Selection
  • An instruction that decides which of two possible
    sequences is executed
  • The decision is based on a single true/false
    condition
  • Examples we saw in class
  • Odd/Even test
  • Letter grade based on points earned
  • Reciprocals

50
Relational Operators
  • Relational Operators are used to compare two
    quantities

EQUAL TO NOT EQUAL TO LESS THAN LESS THAN OR
EQUAL TO GREATER THAN GREATER THAN OR EQUAL TO
! (or, ltgt) lt lt gt gt
51
Testing for Equality
  • To test for equality, use the operator.
  • if ( grade 100 )
  • printf ( Perfect Score! )
  • To test for inequality, use the ! operator
  • if (grade ! 100)
  • printf (Not perfect!)

52
Selection Summary
  • Written in the form of If (condition) Else
    clause
  • Condition should evaluate to true or false
  • Condition can be an expression or a relational
    operation
  • Boolean operations can be used to combine
    multiple conditions into one expression,
    evaluated as a whole
  • If Else clauses can be nested, in which case,
    the else belongs to the nearest if, unless
    specifically indicated otherwise by the use of
    brackets

53
Repetition
  • Repeat an instruction...
  • ...while (or maybe until) some true or false
    condition occurs
  • Test the condition each time before repeating the
    instruction
  • Also known as iteration or loop
  • Example we saw in class
  • Counting and printing the numbers 1 to 10
    consecutively

54
Documentation
  • Records what the algorithm does
  • Describes how it does it
  • Explains the purpose of each component of the
    algorithm
  • Notes restrictions or expectations

55
Algorithm Analysis Overview
  • Once an algorithm has been designed (somehow),
  • and tested for accuracy with several test cases
    of input,
  • how much in the way of resources such as time or
    space (memory) does it require?
  • An algorithm that solves the problem accurately
    but takes a year to complete the solution is
    hardly of much use
  • An algorithm that gives a quick solution but
    needs several million gigabyte (or, unlimited)
    memory and resources is not of much use either

56
Algorithm Analysis Overview
  • How can we estimate the time required for an
    algorithm ?
  • How can we reduce the running time of an
    algorithm from days or years to fractions of
    seconds ?
  • The analysis required to estimate the resources
    used by an algorithm is generally a theoretical
    issue with well-formulated mathematical methods
  • Note that this analysis is not based on any
    program written in a specific language nor does
    it depend on the processor the program is run on
    those are separate issues.
Write a Comment
User Comments (0)
About PowerShow.com