From 7028a9b4c11b0474e9d2382e4f7c7f08d3b9f6ef Mon Sep 17 00:00:00 2001 From: Vinuthna-G-1091 Date: Wed, 4 Mar 2026 18:53:06 +0530 Subject: [PATCH] Removed unused common.h and corrected the print statement in threads-notv --- 02/concurrency/Makefile | 4 ++-- 02/concurrency/common.h | 22 ---------------------- 02/concurrency/threads-notv.c | 3 +-- 02/concurrency/threads.c | 1 - 4 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 02/concurrency/common.h diff --git a/02/concurrency/Makefile b/02/concurrency/Makefile index 5fc9407..3951239 100644 --- a/02/concurrency/Makefile +++ b/02/concurrency/Makefile @@ -2,11 +2,11 @@ all: threads threads-notv CFLAGS=-fcf-protection=none -fno-asynchronous-unwind-tables -m32 -fno-pie -no-pie -threads: threads.c common.h common_threads.h +threads: threads.c common_threads.h gcc $(CFLAGS) -m32 -O1 -S threads.c gcc $(CFLAGS) -m32 -o threads threads.s -Wall -pthread -threads-notv: threads-notv.c common.h common_threads.h +threads-notv: threads-notv.c common_threads.h gcc $(CFLAGS) -m32 -O1 -S threads-notv.c gcc $(CFLAGS) -m32 -o threads-notv threads-notv.s -Wall -pthread diff --git a/02/concurrency/common.h b/02/concurrency/common.h deleted file mode 100644 index 199b622..0000000 --- a/02/concurrency/common.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __common_h__ -#define __common_h__ - -#include -#include -#include -#include - -double GetTime() { - struct timeval t; - int rc = gettimeofday(&t, NULL); - assert(rc == 0); - return (double) t.tv_sec + (double) t.tv_usec/1e6; -} - -void Spin(int howlong) { - double t = GetTime(); - while ((GetTime() - t) < (double) howlong) - ; // do nothing in loop -} - -#endif // __common_h__ diff --git a/02/concurrency/threads-notv.c b/02/concurrency/threads-notv.c index e629273..afd2e4e 100644 --- a/02/concurrency/threads-notv.c +++ b/02/concurrency/threads-notv.c @@ -1,6 +1,5 @@ #include #include -#include "common.h" #include "common_threads.h" int counter = 0; @@ -16,7 +15,7 @@ void *worker(void *arg) { int main(int argc, char *argv[]) { if (argc != 2) { - fprintf(stderr, "usage: threads \n"); + fprintf(stderr, "usage: threads-notv \n"); exit(1); } loops = atoi(argv[1]); diff --git a/02/concurrency/threads.c b/02/concurrency/threads.c index cdcd2b2..7a68cda 100644 --- a/02/concurrency/threads.c +++ b/02/concurrency/threads.c @@ -1,6 +1,5 @@ #include #include -#include "common.h" #include "common_threads.h" volatile int counter = 0;