Sie sind auf Seite 1von 24

School of Computing & Informatics University of Nairobi

CSC 322 Network and Distributed Programming

Course Outline
Concurrent Programming:
Processes and threads, process/thread interaction mechanisms; classical problems in concurrent programming; concurrent programming with threads;

Course Outline
Network programming:
TCP and UDP transport, Introduction to software design models:
Client/server, peer-to-peer etc; Server designs; Networking APIs;

Course Outline
Sockets:
introduction to sockets, socket options, socket types, Name and address conversions; Non blocking I/O; Daemons; Broadcasting and multicasting; Network programming with TCP/IP;

Course Outline
Distributed Programming:
Middleware for distributed applications; Remote Procedure Calls(RPC), Distributed programming using RPC;

Course Outline
Distributed Object based systems:
Distributed objects, Architecture; Communication;

Distributed object programming systems:


Java RMI, CORBA, DCOM; Distributed object based programming using Java RMI and CORBA.

Course Outline
Pre-requisites
CSC221 Object-oriented Analysis, Design and Programming CSC223 Operating Systems CSC225 Computer Networks CSC315 Distributed Systems

Course Outline
Delivery
Lectures Tutorials and Lab sessions

Core Texts
UNIX Network Programming Volume 1: The Sockets Networking API by W.R. Stevens UNIX Network Programming Volume 2: Interprocess communication by W.R. Stevens

Course Outline
Assessment
Examination 50% Coursework 50%

Lectures and Lab sessions


Attendance Electronic handouts provided Linux Computing Environment Projects

Administrative
Collaboration and Cheating
Discussions Hand in only your own work Writeups must be completed independently

Processes and Threads


A process: An execution stream in the context of a particular process state.
Execution stream: A sequence of instructions executed one at a time. A process state: A set of things that can affect or can be affected by a process. Includes: Code, data, registers, stack, open file tables, network connections, memory allocations. Processes are separated. Process is a key OS abstraction to the users.

Processes
Process concepts
Uniprogramming: Runs only one process at a time Multiprogramming: Multiple processes at a time. Processes share resources. Context switch: Save and restore hardware state. Save the state in PCB (Process Control Block).

Process Creation
Caused by the following events
Initiation of a batch job Execution of a process creation system e.g. System initialization User initiated request to create a new process

Process States

Process Termination
Under the following conditions
Normal exit (e.g. exit(0)) Exit on Error (e.g. exit(1)) Fatal error (e.g. segmentation falt) Killed by another process (kill system call)

Threads
A thread:
A unit of sequential execution. An execution stream in the context of a thread state. Unlike processes, multiple threads share parts of their state. E.g. Multiple threads can read and write the same memory location. Each thread still has its own registers, stack, program counter but other threads can read and write the stack memory. Thread Control Block: Typically Registers owned by a thread.

Threads

Threads
Thread Stack Each thread has its own

Threads Implementation
Three approaches:
User-level managed threads Kernel level managed threads Hybrid management approach
Multiplexing user level threads onto kernel level threads

Threads
User-level threads

Threads
Kernel managed threads

Threads
Hybrid implementation approaches

Process/Thread interaction mechanisms

Classical Problems in concurrent programming


Producer-Consumer problem
Race condition.

Semaphores Mutex Locks Monitors Dining Philosphers Readers and Writers Sleeping Barber