From 5a8bfe36c24b7d889f07f3c916f2e69fa2e62f70 Mon Sep 17 00:00:00 2001 From: "Prof. Hyeonuk" <hugang1208@ajou.ac.kr> Date: Sun, 30 Jan 2022 01:19:41 +0900 Subject: [PATCH] report15.md --- lec13/th3.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/lec13/th3.c b/lec13/th3.c index 4c5006b..2ec2f10 100644 --- a/lec13/th3.c +++ b/lec13/th3.c @@ -1,33 +1,35 @@ #include <stdio.h> #include <sys/types.h> #include <unistd.h> - -int bbb = 0; - + +int bbb = 0; + void fn_s() { - char bufff[10]; - static int a = 0; - setvbuf(stdout,bufff, _IOFBF,10); - printf("== %d %d ==",a++, bbb++); + static int a = 0; + printf("== %d %d ==\n",a++, bbb++); } - + void *run (void *arg) { - printf("Hello world of POSIX threads.%d\n", (int) (0)); - for (int i = 0; i < 10; i++) + printf("Hello world of POSXI threads.%d\n", (int) (0) ); + for (int i = 0; i < 100; i++) { - sleep(1); - fn_s(); + sleep(1); + fn_s(); } - return 0; - + return 0; + } - + int main() { int result1; - run((void *) 0); - printf("Thread return %d at the end\n", result1); + run((void *) 0); + sleep(10); + + run((void *) 0); + printf("Thread return %d at the end\n", result1); } + -- GitLab