You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.0 KiB
71 lines
1.0 KiB
#include <stdint.h>
|
|
#include <unistd.h>
|
|
#include <iostream>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <pthread.h>
|
|
#include <cstdlib>
|
|
#include "logger.hpp"
|
|
|
|
static void* task_1(void* arg)
|
|
{
|
|
int i = 0;
|
|
|
|
//for(i = 0; i < 10; i++) {
|
|
while(1) {
|
|
std::cout << "Hello, world!" << std::endl;
|
|
usleep(1000000);
|
|
}
|
|
|
|
|
|
while(1) usleep(10000);
|
|
};
|
|
|
|
static void* task_2(void* arg)
|
|
{
|
|
while(1)
|
|
{
|
|
std::cout << "Task 2"<< std::endl;
|
|
usleep(10000000);
|
|
}
|
|
};
|
|
|
|
|
|
int main(void)
|
|
{
|
|
pthread_t th_task_1;
|
|
pthread_t th_task_2;
|
|
|
|
int check = 0;
|
|
|
|
|
|
Logger logger;
|
|
|
|
check = pthread_create(&th_task_1,
|
|
NULL,
|
|
&task_1,
|
|
NULL);
|
|
if(check != 0) {
|
|
std::cout << "Failed to create thread!" << std::endl;
|
|
exit(-1);
|
|
}
|
|
|
|
|
|
check = pthread_create(&th_task_2,
|
|
NULL,
|
|
&task_2,
|
|
NULL);
|
|
if(check != 0) {
|
|
std::cout << "Failed to create thread!" << std::endl;
|
|
exit(-1);
|
|
}
|
|
|
|
pthread_join(th_task_1,NULL);
|
|
pthread_join(th_task_2,NULL);
|
|
pthread_join(logger.get_handle());
|
|
|
|
return 0;
|
|
}
|
|
|
|
|