From 08dd7aeeb8055352ea01b2c50db3c248e6ab7c45 Mon Sep 17 00:00:00 2001 From: Sohyun Lee <sh119@ajou.ac.kr> Date: Tue, 25 Jan 2022 16:35:30 +0900 Subject: [PATCH] =?UTF-8?q?th3:=EB=AC=B8=EC=A0=9C=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lec13/th3.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lec13/th3.c diff --git a/lec13/th3.c b/lec13/th3.c new file mode 100644 index 0000000..2ec2f10 --- /dev/null +++ b/lec13/th3.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <sys/types.h> +#include <unistd.h> + +int bbb = 0; + +void fn_s() +{ + static int a = 0; + printf("== %d %d ==\n",a++, bbb++); +} + + +void *run (void *arg) +{ + printf("Hello world of POSXI threads.%d\n", (int) (0) ); + for (int i = 0; i < 100; i++) + { + sleep(1); + fn_s(); + } + return 0; + +} + +int main() +{ + int result1; + run((void *) 0); + sleep(10); + + run((void *) 0); + printf("Thread return %d at the end\n", result1); +} + -- GitLab