I am pretty confuse why my program is not working as intended.
I have three similar function:
static void *L1(void *ptr )
{
char *text = (char *)ptr;
int ret;
int fd = open("/dev/L1", O_RDWR);
ret = write(fd, text, strlen(Send)); // Send string to LKM
}
static void *L2(void *ptr )
{
char *text = (char *)ptr;
int ret;
int fd = open("/dev/L2", O_RDWR);
ret = write(fd, text, strlen(Send)); // Send string to LKM
}
static void *L3(void *ptr )
{
char *text = (char *)ptr;
int ret;
int fd = open("/dev/L3", O_RDWR);
ret = write(fd, text, strlen(Send)); // Send string to LKM
}
Next I have a function for creating thread:
static void createKThread(void* (*a)(void *), void* (*b)(void *), void* (*c)(void *))
{
pthread_t t1, t2, t3;
int T1, T2, T3;
T1 = pthread_create(&t1, NULL, a, NULL);
T2 = pthread_create(&t2, NULL, b, NULL);
T3 = pthread_create(&td3, NULL, c, NULL);
pthread_join(t1, NULL);
pthread_join(t2, NULL);
pthread_join(t3, NULL);
}
In my main I am doing :
int main(){
Send2[0] = 'a';
createKThread(L1(&Send[0]), L2(&Send[0]), L3(&Send[0])); //First
Send2[0] = 'b';
createKThread(L1(&Send[0]), L2(&Send[0]), L3(&Send[0])); //Second
return 0;
}
My main program terminates after completion of the first function call `createKThread´. I can't figure out why, I would like the second function call to work and I would like to add more code to my main program. Please advice me on what I am doing wrongly.