Skip to content

Commit

Permalink
feat(kernel): now dispatching duties
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Nicolás Savinelli committed Apr 23, 2022
1 parent 49e93d2 commit 42c3e60
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
6 changes: 6 additions & 0 deletions kernel/inc/server/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
#include "accion.h"
#include "instruction.h"

#include "thread_manager.h"

void *dispatch_imprimir_mensaje(void *args);

void *dispatch_handle_instruction(void *args);

void *dispatch_handle_action(void *args);
24 changes: 24 additions & 0 deletions kernel/src/server/dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include <commons/collections/list.h>

#include "dispatcher.h"
#include "accion.h"
#include "instruction.h"
#include "thread_manager.h"
#include "server.h"
#include "smartlist.h"
Expand Down Expand Up @@ -64,6 +66,28 @@ void *dispatch_imprimir_mensaje(void *args)
return NULL;
}

void *dispatch_handle_instruction(void *args)
{
instruction_t *instruction = ((instruction_t *)args);

THREAD_SAFE(LOG_INFO("Received Instruction: %d %d %d", instruction->icode, instruction->param0, instruction->param1));

instruction_destroy(instruction);

return NULL;
}

void *dispatch_handle_action(void *args)
{
accion_t *accion = ((accion_t *)args);

THREAD_SAFE(LOG_INFO("Received Action: %d %d", accion->actioncode, accion->param););

accion_destroy(accion);

return NULL;
}

// ------------------------------------------------------------
// Getters
// ------------------------------------------------------------
Expand Down
13 changes: 2 additions & 11 deletions kernel/src/server/routines.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,11 @@ void *routine(void *fd)
break;

case SYS:
accion_t *accion = accion_recibir(sender_fd);

LOG_DEBUG("Received Syscall: %d %d", accion->actioncode, accion->param);

accion_destroy(accion);

dispatch_handle_action((void *)accion_recibir(sender_fd));
break;

case CMD:
instruction_t *instruction = recibir_instruction(sender_fd);

LOG_DEBUG("Received Instruction: %d %d %d", instruction->icode, instruction->param0, instruction->param1);

instruction_destroy(instruction);
dispatch_handle_instruction((void *)recibir_instruction(sender_fd));
break;

default:
Expand Down

0 comments on commit 42c3e60

Please sign in to comment.