Skip to content

Commit

Permalink
servers: remove unnecessary locking in server response handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 30, 2024
1 parent d322b92 commit 624c178
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/servers/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ void handleSyscallResponse(const SyscallHeader *hdr) {
}

// default action is to unblock the thread
schedLock();
Process *p = getProcess(req->thread->pid);
req->ret = hdr->header.status;
req->external = false;
req->unblock = true;
req->thread->time = schedTimeslice(req->thread, req->thread->priority);
req->thread->status = THREAD_QUEUED;
//req->thread->status = THREAD_QUEUED;

// some syscalls will require special handling
ssize_t status;
Expand Down Expand Up @@ -99,7 +98,6 @@ void handleSyscallResponse(const SyscallHeader *hdr) {
req->queued = true;
req->next = NULL;
req->retry = true;
schedRelease();
syscallEnqueue(req);
break;
} else if(status < 0) break; // here an actual error happened
Expand All @@ -125,7 +123,6 @@ void handleSyscallResponse(const SyscallHeader *hdr) {
req->queued = true;
req->next = NULL;
req->retry = true;
schedRelease();
syscallEnqueue(req);
break;
} else if(status < 0) break; // here an actual error happened
Expand Down Expand Up @@ -201,6 +198,8 @@ void handleSyscallResponse(const SyscallHeader *hdr) {
case COMMAND_EXEC:
if(hdr->header.status) break;

schedLock();

int execStatus = execveHandle((ExecCommand *) hdr);

if(!execStatus) {
Expand Down Expand Up @@ -230,5 +229,5 @@ void handleSyscallResponse(const SyscallHeader *hdr) {
}

platformSetContextStatus(req->thread->context, req->ret);
schedRelease();
req->thread->status = THREAD_QUEUED;
}

0 comments on commit 624c178

Please sign in to comment.