목록전체 글 (351)
printf("ho_tari\n");
#include #include #include #include #include #include void error_handling(char *message); int main(int argc, char *argv[]) { int serv_sock; int clnt_sock; struct sockaddr_in serv_addr; struct sockaddr_in clnt_addr; socklen_t clnt_addr_size; char message[]="Hello World!"; if(argc!=2){ printf("Usage : %s \n", argv[0]); exit(1); } serv_sock=socket(PF_INET, SOCK_STREAM, 0); if(serv_sock == -1) error..
#include #include #include #define LED1 23 #define LED2 24 #define SW1 4 #define SW2 17 int led1_flag = 0; int led2_flag = 0; int sw1_flag = 0; int sw2_flag = 0; pthread_t thread1, thread2; void *led1(void *arg) { while (1) { if (led1_flag == 1) { digitalWrite(LED1, HIGH); delay(300); digitalWrite(LED1, LOW); delay(300); } } } void *led2(void *arg) { while (1) { if (led2_flag == 1) { digitalWrit..
#include #include #include #include #include void* thread_main(void *arg); int main(int argc, char *argv[]) { pthread_t t_id; int thread_param=5; void * thr_ret; if(pthread_create(&t_id, NULL, thread_main, (void*)&thread_param)!=0) { puts("pthread_create() error"); return -1; }; if(pthread_join(t_id, &thr_ret)!=0) { puts("pthread_join() error"); return -1; }; printf("Thread return message: %s \n..
#include #include #include void* thread1_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..1"); } return (void*)10; } void* thread2_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..2"); } return (void*)20; } int main(int argc, char *argv[]) { pthread_t t1_id, t2_id; int thread_p..
#include #include #include void* thread1_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..1"); } return NULL; } void* thread2_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread..2"); } return NULL; } int main(int argc, char *argv[]) { pthread_t t1_id, t2_id; int thread_param = 5; ..
#include #include #include void* thread_main(void *arg) { int i; int cnt = *((int*)arg); for (i = 0; i < cnt; i++) { sleep(1); puts("running thread\n"); } return NULL; } int main(int argc, char *argv[]) { pthread_t t_id; int thread_param = 5; if (pthread_create(&t_id, NULL, thread_main, (void*)&thread_param) != 0) { puts("pthread_create() error\n"); return -1; } sleep(7); puts("end of main\n"); ..
#include #include #define LED_1 23 #define SW_1 4 int LED1_flag = 0; int SW1_flag = 0; void sw_interrupt() { if (LED1_flag == 0) { digitalWrite(LED_1, HIGH); LED1_flag = 1; } else { digitalWrite(LED_1, LOW); LED1_flag = 0; } SW1_flag = 1; } int main(void) { if (wiringPiSetupGpio() == -1) return -1; // BCM pinMode(LED_1, OUTPUT); pinMode(SW_1, INPUT); digitalWrite(LED_1, LOW); wiringPiISR(SW_1, I..