From c7b0fa80ee9531aafcfce6d249cb07102005ecae Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 7 Mar 2007 03:07:47 +0000 Subject: [PATCH] bugs --- Robust/src/Benchmarks/WebServerJava/Logger.java | 4 ++-- Robust/src/Runtime/thread.c | 15 ++++++++++++++- Robust/src/Runtime/thread.h | 2 +- Robust/src/buildscript | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Robust/src/Benchmarks/WebServerJava/Logger.java b/Robust/src/Benchmarks/WebServerJava/Logger.java index a23cc4fa..be29b3d3 100644 --- a/Robust/src/Benchmarks/WebServerJava/Logger.java +++ b/Robust/src/Benchmarks/WebServerJava/Logger.java @@ -10,14 +10,14 @@ public class Logger { } //Logs filename as per client requests - public void logrequest(String filename){ + public synchronized void logrequest(String filename){ String request = new String("\nNew Request received: "); fos.write(request.getBytes()); fos.write(filename.getBytes()); fos.flush(); } - public void logrequest(){ + public synchronized void logrequest(){ String request = new String("\nNew Request received: "); fos.write(request.getBytes()); fos.flush(); diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 54ea0b55..7c22e069 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -5,6 +5,7 @@ #include #include "thread.h" #include "option.h" +#include #include int threadcount; @@ -79,8 +80,20 @@ void initthread(struct ___Thread___ * ___this___) { void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) { pthread_t thread; + int retval; + pthread_attr_t nattr; + pthread_mutex_lock(&gclistlock); threadcount++; pthread_mutex_unlock(&gclistlock); - pthread_create(&thread, NULL,(void * (*)(void *)) &initthread, VAR(___this___)); + pthread_attr_init(&nattr); + pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED); + + do { + retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___)); + if (retval!=0) + usleep(1); + } while(retval!=0); + + pthread_attr_destroy(&nattr); } diff --git a/Robust/src/Runtime/thread.h b/Robust/src/Runtime/thread.h index 0062c6bc..5bb5d19c 100644 --- a/Robust/src/Runtime/thread.h +++ b/Robust/src/Runtime/thread.h @@ -1,7 +1,7 @@ #ifndef THREAD_H #define THREAD_H #include "methodheaders.h" -#include "pthread.h" +#include extern int threadcount; extern pthread_mutex_t gclock; diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 689a32b9..cb7a0f11 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -84,7 +84,7 @@ EXTRAOPTIONS="$EXTRAOPTIONS -O9" elif [[ $1 = '-thread' ]] then JAVAOPTS="$JAVAOPTS -thread" -EXTRAOPTIONS="$EXTRAOPTIONS -DTHREADS" +EXTRAOPTIONS="$EXTRAOPTIONS -DTHREADS -lpthread" elif [[ $1 = '-curdir' ]] then CURDIR=$2 -- 2.34.1