-
Notifications
You must be signed in to change notification settings - Fork 0
/
myFunctions.c
73 lines (60 loc) · 1.65 KB
/
myFunctions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* File : myFunctions.c
*
* Description : This file contains the definitions of the functions that are going
* to be used in the workFunction struct.
*
* Author : Michael Karatzas
* Date : March 2020
*
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include "myFunctions.h"
//Definition of the workFuctions that will used in the queue.
void * calc5thPower(void * arg){
int number= (int) arg;
signed long power=1;
for(int i=1;i<=5;i++)
power=power*number;
// printf("The arg number is %d and its power is %ld ! \n", number,power);
}
void * calcCos(void * arg){
int number;
float myCos;
number= (int) arg;
for(int i=1;i<=FUNC_REPS;i++)
myCos=cos((float)( (i*number* PI) / 180) );
// printf("The arg number is %d and its cosine is %f ! \n", number,myCos);
// usleep(500);
}
void * calcSin(void * arg){
int number;
float mySin;
number= (int) arg;
for(int i=1;i<=FUNC_REPS;i++)
mySin=sin((float)( (i* number* PI) / 180) );
// printf("The arg number is %d and its sine is %f ! \n", number,mySin);
// usleep(500);
}
void * calcCosSumSin(void * arg){
int number;
float mySin;
float myCos;
number= (int) arg;
mySin=sin((float)( (number* PI) / 180) );
myCos=cos((float)( (number* PI) / 180) );
// printf("The arg number is %d its cosine is %f, its sine is %f and their sum is %f ! \n", number,myCos,mySin, myCos+mySin);
// usleep(500);
}
void * calcSqRoot(void * arg){
int number;
float myRoot;
number= (int) arg;
myRoot= sqrt((float)number);
// printf("The arg number is %d and its square root is %f ! \n", number,myRoot);
// usleep(500);
}