$Revision: 1.8 $
Example code: A thread.
Status: NOT REVUED, NOT TESTED
Authors: Chris Ottrey
Joao Damas
- Online References:
-
Included Files
Preprocessor definitions
String sizes
#define STR_S 63
#define STR_M 255
#define STR_L 1023
#define STR_XL 4095
#define STR_XXL 16383
typedef struct th_args th_args
struct th_args |
|
{ |
|
void* function; |
|
int sock; |
|
} |
|
Mutex lock. Used for synchronizing changes.
pthread_mutex_t Whois_thread_count_lock
pthread_mutex_t Config_thread_count_lock
pthread_mutex_t Mirror_thread_count_lock
The number of threads.
int Whois_thread_count
int Config_thread_count
int Mirror_thread_count
Aquire a readers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_acquire_read_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Aquire a writers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_acquire_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Handle config connections.
More:
Author:
joao
void TH_do_config ( void* arg )
- void* arg
- The socket to connect to. (It has to be passed in this way for this
thread routine.)
Handle whois connections.
More:
Author:
joao
void TH_do_whois ( void* arg )
- void* arg
- The socket to connect to. (It has to be passed in this way for this thread routine.)
int TH_get_id ( void )
Initialize a readers/writers lock.
Side effect: the lock is set to open(?)
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_init_read_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Release a readers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_release_read_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
Release a writers lock.
Reference: "Multithreaded Programming Techniques - Prasad p.192"
More:
Author:
ottrey
void TH_release_write_lock ( rw_lock_t* prw_lock )
- rw_lock_t* prw_lock
- Readers writers lock.
This is the routine that creates the main threads.
More:
Author:
ottrey
joao
void TH_run ( int sock, void* do_function )
- int sock
- The socket to connect to.
void * do_function The function to call for each type of service
- void* do_function
-
void TH_run2 ( void* function )
char* TH_to_string ( void )
static void log_print ( const char* arg )
Waits for an incoming connection on the and spawns a new thread to handle it.
More:
Author:
ottrey
joao
static void* main_thread ( void* arg )
- void* arg
- Pointer to a struct containing the socket to talk to the client and
the function to call depending on the incoming connection.