Computer Science  >  Research Paper  >  Wilfrid Laurier UniversityCP 386A3.txt (All)

Wilfrid Laurier UniversityCP 386A3.txt

Document Content and Description Below

#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sys/stat.h> #include <time.h> //Angela Tran //180392140 //tran2140 void logStart ... (char* tID);//function to log that a new thread is started void logFinish(char* tID);//function to log that a thread has finished its time void startClock();//function to start program clock long getCurrentTime();//function to check current time since clock was started time_t programClock;//the global timer/clock for the program sem_t global; sem_t even; sem_t odd; int curr = 0; int prev = 0; typedef struct thread //represents a single thread, you can add more members if required { char tid[4];//id of the thread as read from file unsigned int startTime; int state; pthread_t handle; int retVal; } Thread; //you can add more functions here if required int threadsLeft(Thread* threads, int threadCount); int threadToStart(Thread* threads, int threadCount); void* threadRun(void* t);//the thread function, the code executed by each thread int readFile(char* fileName, Thread** threads);//function to read the file content and build array of threads int main(int argc, char *argv[]) { if(argc<2) { printf("Input file name missing...exiting with error code -1\n"); return -1; } //you can add some suitable code anywhere in main() if required //initilization sem_init(&global, 0, 1); sem_init(&even, 0, 1); sem_init(&odd, 0 ,1); Thread* threads = NULL; int threadCount = readFile(argv[1],&threads); startClock(); while(threadsLeft(threads, threadCount)>0)//put a suitable condition here to run your program [Show More]

Last updated: 3 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of Wilfrid Laurier UniversityCP 386A3.txt document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$8.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

79
0

Document information


Connected school, study & course


About the document


Uploaded On

Jul 08, 2021

Number of pages

4

Written in

All

Seller


Profile illustration for Cheryshev
Cheryshev

Member since 4 years

102 Documents Sold

Reviews Received
6
4
1
0
1
Additional information

This document has been written for:

Uploaded

Jul 08, 2021

Downloads

 0

Views

 79

Document Keyword Tags

Recommended For You

Get more on Research Paper »

$8.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·