Skip to content
Snippets Groups Projects
Commit d866979a authored by John Romein's avatar John Romein
Browse files

bug 225:

Terminates properly with interrupts.  Still unstable.
parent 83675e4d
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <vector> #include <vector>
#include <pthread.h> #include <pthread.h>
#include <signal.h>
#include "fcnp_ion.h" #include "fcnp_ion.h"
#include "protocol.h" #include "protocol.h"
...@@ -108,7 +109,7 @@ static int fd; ...@@ -108,7 +109,7 @@ static int fd;
static _BGP_Atomic sendMutex = {0}; static _BGP_Atomic sendMutex = {0};
static pthread_mutex_t scheduledRequestsLock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t scheduledRequestsLock = PTHREAD_MUTEX_INITIALIZER;
static Semaphore recvSema(1); // could have used mutex, but this is slower!??? livelock??? static Semaphore recvSema(1); // could have used mutex, but this is slower!??? livelock???
static volatile bool stop; static volatile bool stop, stopped;
// Reading the tree status words seems to be expensive. These wrappers // Reading the tree status words seems to be expensive. These wrappers
...@@ -374,6 +375,7 @@ static void *pollThread(void *) ...@@ -374,6 +375,7 @@ static void *pollThread(void *)
if (useInterrupts) if (useInterrupts)
std::clog << "received " << nrInterrupts << " vc0 interrupts" << std::endl; std::clog << "received " << nrInterrupts << " vc0 interrupts" << std::endl;
stopped = true;
return 0; return 0;
} }
...@@ -564,11 +566,26 @@ static void drainFIFO() ...@@ -564,11 +566,26 @@ static void drainFIFO()
static pthread_t thread; static pthread_t thread;
static void sigHandler(int)
{
}
void init(bool enableInterrupts) void init(bool enableInterrupts)
{ {
if (enableInterrupts) if (enableInterrupts) {
std::clog << "Warning: FCNP with interrupts is not stable!" << std::endl; std::clog << "Warning: FCNP with interrupts is not stable!" << std::endl;
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = sigHandler;
if (sigaction(SIGUSR1, &sa, 0) != 0)
perror("sigaction");
}
useInterrupts = enableInterrupts; useInterrupts = enableInterrupts;
//setAffinity(); //setAffinity();
...@@ -586,6 +603,14 @@ void end() ...@@ -586,6 +603,14 @@ void end()
{ {
stop = true; stop = true;
if (useInterrupts)
while (!stopped) {
if (pthread_kill(thread, SIGUSR1) != 0)
perror("pthread_kill");
usleep(25000);
}
if (pthread_join(thread, 0) != 0) { if (pthread_join(thread, 0) != 0) {
perror("pthread_join"); perror("pthread_join");
exit(1); exit(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment