threadpool-handout - CS3214 Fall 2011 Project 5 Thread...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Project 5 - “Thread Pools and Futures” Due: Wednesday, Nov 16, 2011. 11:59pm. (Late days may be used.) What to submit: Upload a tar ball using the p5 identifier that includes the following files: - threadpool.c with your code. - speedup.pdf with your analysis. Use a suitable word processing program to produce the PDF file. We will be using the provided file to test your code. You should do this project on the machines of the rlogin cluster. 1 Thread Pools and Futures In this project, you will practice the use of mutexes, condition variables, and semaphores by creating a partial implementation of a thread pool and futures. The thread pool and the futures should implement functionality similar to the Executor and Future classes provided in the Java standard libraries by defining the following API: / * Create a new thread pool with n threads. * / struct thread_pool * thread_pool_new(int nthreads); / * Shutdown this thread pool. May or may not execute already queued tasks. * / void thread_pool_shutdown(struct thread_pool * ); / * A function pointer representing a ’callable’ * / typedef void * ( * thread_pool_callable_func_t) (void * data); / * Submit a callable to thread pool and return future. * The returned future can be used in future_get() and future_free() * / struct future * thread_pool_submit( struct thread_pool * , thread_pool_callable_func_t callable, void * callable_data); / * Make sure that thread pool has completed executing this callable, * then return result. * / void * future_get(struct future * ); / * Deallocate this future. Must be called after future_get() * / void future_free(struct future * ); The implement these functions, you will have to define private structures struct future and struct thread pool in threadpool.c . A future should store a pointer to the function to be called, any data to be passed to that function, as well as the result (when available). You should use a semaphore to communicate whether a future’s result is avail- able. Created by G. Back ([email protected])
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/31/2011 for the course CS 3214 taught by Professor Staff during the Fall '11 term at Virginia Tech.

Page1 / 4

threadpool-handout - CS3214 Fall 2011 Project 5 Thread...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online