• Mode-1 Multi-Core • Memory Allocators • OpenMP • Intel TBB • Pthreads • Java - Threads • Charm++ Prog. • Message Passing (MPI) • MPI - OpenMP • MPI - Intel TBB • MPI - Pthreads • Compiler Opt. Features • Threads-Perf. Math.Lib. • Threads-Prof. & Tools • Threads-I/O Perf. • PGAS : UPC / CAF / GA • Power-Perf. • Home




Programming on Multi-Core Processors Using Pthreads (POSIX Threads)

PEMG-2010 Mode-1 : POSIX Thread Programming (Pthreads)

Write a pthreads program that implements a simple streaming media player by making use of unix/windows socket library on Multi-Core processors based on Pthread APIs. The program must implement all of the aspects mentioned below:

1.
Thread 1 : Network Thread This thread is meant for the purpose of monitoring a particular network port for incoming data.
2.
Thread 2 : Decompressor Thread This thread is meant for the purpose of decompressing the incoming data and generating the video frames in sequence.
3.
Thread 3 : Renderer Thread This thread is meant for the purpose of displaying the generated video frames at predefined intervals
4.
The above 3 threads must communicate using shared buffers - An in-buffer between Network and the decompressor threads - An out-buffer between the decompressor and renderer threads
5.
The Network thread calls the listen_to_port() to gather network from the data ( which internally uses socket , bind and listen calls to listen for incoming data on a particular port ). For the sake of this assignment let the incoming data be a set of randomly generated strings coming to the port from a seperate server program.
6.
The incoming data recieved by the Network thread is placed in the In-buffer (in the sequence of arrival).
7.
The Decompressor thread calls the decompress() which takes in data from the In-buffer and returns a frame of predefined size.For the sake of this assignment take data of predefined size from the In-buffer, and use it to fill in a struct frame and write the structure to the Out-buffer.
8.
The Renderer thread pick data frames from the Out-buffer and calls the display() which prints the data contained within the frames on to the screen.
9.
The thread framework described above is to be implemented by means of condition variables.
10.
Function Calls to be incorporated : pthread calls : pthread_create, pthread_mutex_init, pthread_mutex_destroy, pthread_cond_init, pthread_cond_destroy, pthread_mutex_lock , pthread_mutex_lock, pthread_cond_wait, pthread_cond_signal. socket calls : socket, bind, listen, connect,accept , send, recv.
shared memory calls: shmget, shmat, shmdt
Centre for Development of Advanced Computing