Skip to content

Instantly share code, notes, and snippets.

View IshJ's full-sized avatar

Ishadi Jayasinghe IshJ

View GitHub Profile
void* Thread_Operation() {
while (totalCount < m) {
// Variable to randomly generate values for operations
int random_value = rand() % 65535;
// Variable to randomly select one of the three operations
int random_select = rand() % 3;
// Member operation
threadOperation(){
.
.
.
if(memberFunction){
pthread_rwlock_rdlock(&rwlock);
Member(random_value, head);
pthread_rwlock_unlock(&rwlock);
}
if(insertFunction){
pthread_mutex_lock(&total_mutex);
totalCount++;
pthread_mutex_unlock(&total_mutex);
jkl
jhkhl
jkljklj;ljlkj