25
1 Overview of Operating System and Networking Lecture 1 Computer Architecture Computer architecture

Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

1

Overview of Operating System

and Networking

Lecture 1

Computer Architecture

Computer architecture

Page 2: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

2

Computer Architecture CPU

does arithmetic and logic operations

Executes instructions

Memory

stores instructions and data, e.g. programs

How does CPU access memory?

I/O devices

e.g. hard disks, monitor, CD-ROM have a control card communicating with CPU through buses

(ISA, PCI, USB)

How does CPU control I/O devices?

Interrupts/traps and registers

How does a program get started?

Origin of OS

From where to load a program into the memory in

the past?

Punch cards, punch tapes, hard disks

How to load a program in the early days?

A loading program is written to read cards/tapes and then

store the instructions into the memory

One of the first device drivers

Every programmer had to write the loading

program!

Page 3: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

3

Operating System

Why not share the same loading program among the programmers? The initial motivation for writing a piece of OS

What is OS? Includes kernel and many system programs

One or more programs which can be reused to conveniently use/share computer resources such as I/O devices

Control program

Wrapper

Resource allocator

Lazy government

Service provider

OS Concepts

OS kernel

Provide the most basic and generic functionality

Handle resource sharing and I/O devices

Can only be used by system calls

System calls

Used to get services from OS

Routines/kernel functions

For system calls and interrupts

Page 4: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

4

OS Concepts

Daemons/servers Achieves the functions of OS but running as a user program

providing a service

Keep the OS kernel as small as possible

E.g. sshd, syslogd, named, crond

Command shell

A user interface based on command line

A layer of software which wraps the OS kernel in more

acceptable clothes Allows users to interact with the machine, e.g. manipulate

files, and run programs Interpret scripts, e.g. Bourne shell, Bourne Again SHell

(BASH), C shell, Python, Perl...

Shell programming (scripting)

Why shell programming?

It is essential for system administrators (SAs)

Many administrative programs are written in scripts

The syntax is simple and easy to learn and understand

Quickly prototype a complex application

When efficiency and performance are essential, don’t use shell scripts

BASH(Bourne Again Shell)

Extended from the classic Bourne shell and Korn shell

A de facto standard for scripting on UNIX

Page 5: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

5

Processes

Process

A program which is being executed

Consists of program and its running state

Why processes?

For convenient resource sharing

Time sharing: processes take turns to be executed

Tasks/jobs/threads

Scheduling of processes

Round-robin/queueing

Preemptive/non-preemptive

Processes

Context switching

Restore the state of a process when it is scheduled to run

The state of each process is described by a data structure called process control block (PCB)

Inter-process communication

Pipes: enables one process to open another process as if it were a file for writing or reading, e.g. ls -l | more

Sockets: IP domain or Unix domain

Data sharing and synchronisation

Page 6: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

6

Processes

Process creation fork(), wait(), and exec()

Parent and child processes

Process scheduling state

Ready: in line to be executed

Running: active

Waiting: sleeping or suspended

Terminated: defunct/zombie

Deadlock Due to resource sharing and waiting among processes

Memory system

RAM/ROM

Paging

Divided into pages, e.g. 4096 (4k) bytes

Addressing: page_id + offset

Logical memory

To protect each program’s memory space, logical memory space is used for each program

Each program has its own separate logical memory space starting at address zero, divided into code and data segment

Page 7: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

7

Memory system

Logical vs. Physical memory

There is a mapping mechanism from logical to physical memory space. It is called a page table. It is loaded as part of the context switching

malloc() and free() to allocate and free logical memory.

The figure below shows the relationship between segments, logical pages, and physical page frames.

Memory system Virtual memory A way of making the physical memory of a computer effectively larger

than it really is.

Disk space (swap space) is used to store memory pages

Swapping: an entire process, including code and data, is expunged frommemory

Paging: only some single pages are swapped out

Page faults

Occurs when a page is not in the memory

When a page fault happens, the involved page has to be brought in from disk space.

Page 8: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

8

Memory system

Paging strategies

When a page fault occurs, some page in memory has to be shifted out

FIFO

LRU

Thrashing

a state where there are so many processes competing for limited resources that it spends more time servicing page faults and swapping in and out processes than it does executing the processes

I/O system

I/O devices are handled with drivers

Drivers provide functions of device operations under a standard interface (a file) to user programs, e.g., open(), read(), and write().

Devices are operated by reading from/writing into I/O memory or ports

Drivers may be loaded as modules in Linux

Character and block devices

Depend on if data are manipulated as a stream of bytes or blocks. Block buffer are used for block devices

Synchronous and Asynchronous I/O

Page 9: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

9

I/O system Interrupts are used for devices with asynchronous I/O

A small piece of code in OS is used to handle each interrupt

Interrupt vector: contains addresses of the interrupt routines

Direct Memory Access (DMA): a device which copies blocks of data at a time from one place to the other, without the intervention of the CPU. Very high speed devices could place heavy demands on the CPU if

they relied on the CPU to copy data word by word.

File system

File system

To directly operate disks (block devices) is troublesome and complicated

A file is a good abstraction for data stored on block devices

A file system is a high level interface to block devices such as disks. It consists of methods and data structures that an operating system uses to keep track of files on a disk

There are many different file systems, e.g. Linux supports ext2, fat, nfs, iso9660, …

Page 10: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

10

Linux OS

A member of the UNIX family

Inspired by MINIX

Initially developed by Linus Torvalds, but contributed by hundreds of developers around the world

Linux source code is under GNU General Public License, which is open to anyone to study

Linux OS kernel

A true UNIX kernel, but not a full UNIX OS, as it doesn’t include all applications such as windowing systems, compilers, and text editors which are available under the GNU license

Linux OS

Characteristics of Linux OS

A monolithic kernel

Supports kernel modules

Multithreading

Preemptive for 2.6 (but non-preemptive for earlier versions)

Multiprocessor support

Reconfigurable kernel

Linux version

X.Y.ZZ - X.Y identifies the version number, ZZ is the release number. If Y is an even number, the version is a stable version

Page 11: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

11

Networking

OSI Model

OSI model

Seven layers

Protocol encapsulation

Five layers in Internet: physical, data link, network, transport (including presentation and session layers of OSI model), application

A guideline for writing network software and understanding the principle of internetworking

You can’t see the layers as a network user

Page 12: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

12

Basic components Repeaters

Regenerate signals

Hubs

Similar to repeaters but with multiple ports

Repeater hubs

a repeater with many ports (only physical layer)

Switching hubs

Parallel transmission paths

Smarter (understand MAC layer)

Auto-negotiation and flow control

Auto-negotiation is defined in IEEE 802.3

Two connected devices can choose common

transmission parameters such as speed

How can a NIC work with different cables with

different speed?

Media Independent Interface (MII) defined by IEEE

802.3u

How can a slow NIC handle fast traffic from a fast

NIC?

PAUSE frame in IEEE 802.3x

Eventually should be handled by higher layer protocols

Page 13: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

13

Basic components

Bridges (with multiple ports)

Store and forward frames (up to OSI layer 2)

Switches: similar to multiport bridges (up to 1.5 layer)

Mainly work at MAC sublayer.

Router

Route and forward network packets (OSI layer 3)

Modems (hard to say, could be up to layer 3)

ADSL modem/router

Basic components

Firewall (up to layer 3 or 4)

a dedicated software (maybe with hardware support), which inspects network traffic passing through it, and denies or permits passage based on a set of rules.

Gateway (up to application layer)

a device that serves as an entrance to a network.

Similar to a firewall, but has more knowledge of application protocols and better security.

Page 14: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

14

Network Hardware

Cables

Twisted pair, coaxial cable, optical fibre

Connectors

RJ-45 for UTP

Twisted-pair cables

Twisted-pair categories

Cat 1 and 2, Cat 3, Cat 4, Cat 5 and 5e, Cat 6

Crosstalk

Signal crosstalk occurs when the signals in one wire are eletromagnetically coupled (or cross over) into another wire. This happens because wires in close proximity to one another can pick up each other’s signal.

Problem: phantom collisions can be detected.

Crossover cable Directly networking two computers.

Page 15: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

15

Structured cabling

High-quality cabling is essential to network

performance

Structured cabling provides a reliable and

manageable cabling system

TIA/EIA cabling standards

Telecommunications Industries Association

(TIA)

Electronic Industries Association (EIA)

Refer to Ethernet: The Definitive Guide

Structured cabling

Page 16: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

16

Network Hardware

BNC T connector for coaxial

SMA, ST and SC connectors for optical fiber

Network Hardware

Transceivers (normally embedded)

Used in Ethernet to connect nodes to the physical medium

Page 17: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

17

Network Hardware

Network Interface Card

CSMA/CD

Network device driver is used by OS to interact with NIC. An interrupt is used when a request is completed or when a packet arrives.

DMA: Direct Memory Access is used to copy data from NIC (device) memory to main memory (RAM)

Protocol stack: layer 1, layer 1.5 (MAC)

Internet Protocol

MAC address

Six octets for Ethernet NIC

3b-00-65-fa-4a-68

IP address (IPv4)

4 bytes (octets), e.g. 132.65.33.24

Traditionally addresses are divided into class A, B

and C

Classless Inter-Domain Routing (CIDR)

Page 18: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

18

Internet Protocol

Subnets

Use net mask to identify a subnet

E.g. divide class B network 132.65. into 254 subnets.

Net mask is 255.255.255.0

Subnets are

132.65.1/24

132.65.2/24

132.65.254/24

Broadcast address and network address E.g. 132.65.255.255, 132.65.0.0

More exercises for sub-netting in Lab

Ethernet frame

Frame type serves two purposes

Length (<=1500)

Frame type (>= 1536 or 0x0600)

Page 19: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

19

IP packet

UDP datagram & TCP segment

Page 20: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

20

Topology & Protocols

Network topology

Star, bus, ring, mesh, hybrid

Physical vs. logical topology

LAN protocols

Ethernet/Fast Ethernet/Gigabit Ethernet/10 Gigabit

Token ring

Token bus

FDDI

IPX

Protocols

WAN protocols

X.25

Frame relay

ATM

ISDN

Internetworking

TCP/IP

IPv4 vs IPv6

PPP for dial up networking

ARP/RARP

Page 21: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

21

High speed interconnects

DSL e.g. ADSL, VDSL

Use telephone line, with upstream 128kbps, and downstream up to 8Mbps

InfiniBand

Primarily used for high performance computing

Point to point bi-directional link, 2.5 Gbps in each direction, between processor and storage device

12x links are used for cluster computers

FibreChannel

Gigabit speed network technology similar to InfiniBand

IEEE standards

802.3 for Ethernet

Includes supplements for fast Ethernet, Gigabit

Ethernet, and 10 Gigabit Ethernet

802.5 for Token Ring

802.4 for Token Bus

802.11 for wireless LAN

Includes supplements a, b and g

Page 22: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

22

I/O Bus standards

Industry Standard Architecture (ISA)

Good old standard

Used for slower devices such as mice and modem

Peripheral Component Interconnect (PCI)

Used to connect performance critical devices such as video card and NIC to memory

Will be succeeded by PCI Express

Refer to http://www.techfest.com/hardware/bus.htmfor other I/O bus standards

Client/server Model

Many network functions are implemented in

client/server model

Client: make a request

Server: process requests from clients and reply

Clients and servers are programs.

Many servers are just installed on a single powerful machine

for easy administration. Therefore that machine is normally

called a “server” machine.

Port numbers/well-known port numbers

The counterpart is Peer-to-Peer (P2P) model.

Page 23: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

23

Client/Server Model

Typical servers Name server: provide a mapping between IP addresses and IP names.

Try dig www.hotmail.com

File server: provide network file service

Exmple - NFS

email server: provide email service

Example - sendmail, smtpd

www server: provide web service

Example - apache

Printer server: provide print service

Example - lpd

ftp server: ftpd

ssh server: sshd

The journey of an IP packet – a

holistic view

Page 24: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

24

Kernel space and userspace

The memory of a computer system (like a client or

server machine) is separated into kernel space and

user space.

User data like email or HTTP request are in user

space but transferred to the kernel space for

processing via system calls.

Functions like TCP/UDP, IP are in the privileged

kernel space and handle the encapsulation of

packets like creating headers for the packets or

frames and the sending/receiving of the packets.

Data path between client/server Copy data from the user process (user memory) to socket

in OS kernel (kernel memory)

Add headers to the data to make a frame

Copy to NIC memory using DMA

Send the frame by NIC to the a router

The IP packet travels from router to router, finally to the server

Receive the frame by the NIC of the server

NIC sends interrupts to CPU

CPU invokes NIC driver to copy the frame to RAM (using DMA)

Headers are processed by related protocols

Copy data from the receiving socket (kernel memory) to the buffer of the user process (maybe a web server)

Page 25: Overview of Operating System and Networkingamansystem.com/apps/people/sallay/SNA/slides/SNA-Lecture1.pdf · Context switching Restore the state of a process when it is scheduled to

25

Questions