Browse Source

restore lock in exec_blas_async to prevent race on queue

pull/4112/head
Mark Seminatore 2 years ago
parent
commit
4083ef2f6b
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      driver/others/blas_server_win32.c

+ 12
- 1
driver/others/blas_server_win32.c View File

@@ -75,6 +75,7 @@ int blas_server_avail = 0;
/* Local Variables */
static BLASULONG server_lock = 0;

static BLASULONG pool_lock = 0;
static blas_pool_t pool;
static HANDLE blas_threads [MAX_CPU_NUMBER];
static DWORD blas_threads_id[MAX_CPU_NUMBER];
@@ -420,7 +421,17 @@ int exec_blas_async(BLASLONG pos, blas_queue_t *queue){
pos ++;
}

pool.queue = queue;
LOCK_COMMAND(&pool_lock);

if (pool.queue) {
current = pool.queue;
while (current -> next) current = current -> next;
current -> next = queue;
} else {
pool.queue = queue;
}

UNLOCK_COMMAND(&pool_lock);

// start up worker threads
ReleaseSemaphore(pool.taskSemaphore, pos - 1, NULL);


Loading…
Cancel
Save