My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
DesignDocument  
Design Document pthread-lib
Updated Sep 13, 2007 by powers.n...@gmail.com

This is the design document for pthread-lib. You will find the exact specification of what each piece of code was designed.

1 Core Design

1.1 Data Structures

1.1.1 An expandable array of thread pool pointers (THREAD_POOL). This allows the programmer to create multiple pools of threads

1.1.2 An expandable array of function pointers. This will function as the queue that work will be submitted to. This should be able to be assigned to any pool or every pool. For example, pool A gets function pointers from queue 1 and queue 2 while pool B gets function pointers from queue 2 only. This and any configuration should be possible.

1.1.3 A THREAD_POOL struct that contains a core_pool_size, max_pool_size, keep_alive_time, curr_pool_size,

1.1.4 A THREAD_POOL_STATE struct that consists of RUNNING=0, SHUTDOWN=1, STOP=2, TERMINATED=3

1.1.5 A THREAD struct that contains various information about a thread.

1.1.5.1 TODO: what data should be in the THREAD struct?

1.2 Methods

public methods

1.2.1 submit(function_pointer) - submits the function pointer to be executed

1.2.2 submit(function_pointer, queue)

1.2.3 submit(function_pointer, pool)

1.2.4 awaitTermination(long timeOut) - wait for the pools to terminate

1.2.5 purge() - remove all the data in the queue

1.2.6 shutdown()

private methods

1.2.? addThread - adds a thread to the pool up to max_pool_size if demand is high

1.2.? poll - waits to get a task from the assigned queues (must have alg. for checking multiple queues

1.2.? take - takes the function pointer off the queue and executes it (must have mutex)

2 Thread Manager

2.1 beginManaging()

2.2 stopManaging()

2.3 checkThreads()

2.4 stopThreadPool()

3 Signal Handler

3.1 int signal_handler_create(FUNCTION_PTRS function_ptrs)

3.2 void stop_signal_manager()

3.3 void destroy_signal_manager()

3.4 void signal_handler_function(void functions)

3.5 int block_all_signals()

4 Wrapper Functions


Sign in to add a comment
Powered by Google Project Hosting