Skip to content

Commit

Permalink
feat(cpu): handle pcb from module CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasanchez committed Apr 23, 2022
1 parent 9e28760 commit 60cf776
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cpu/include/server/pcb_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file pcb_controller.h
* @author Tomás Sánchez <tosanchez@frba.utn.edu.ar>
* @brief
* @version 0.1
* @date 04-23-2022
*
* @copyright Copyright (c) 2022
*
*/

#pragma once

#include "pcb.h"
#include "server.h"

// ============================================================================================================
// ***** Public Functions *****
// ============================================================================================================

/**
* @brief Receivesa a PCB stream.
*
* @param fd the file descriptor
* @return a new PCB instance
*/
pcb_t *receive_pcb(int fd);
36 changes: 36 additions & 0 deletions cpu/src/server/pcb_controller.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file pcb_controller.c
* @author Tomás Sánchez <tosanchez@frba.utn.edu.ar>
* @brief
* @version 0.1
* @date 04-23-2022
*
* @copyright Copyright (c) 2022
*
*/
#include <stdlib.h>
#include "pcb_controller.h"
#include "log.h"

// ============================================================================================================
// ***** Definitions *****
// ============================================================================================================

#define LOG_PCB(pcb) \
{ \
LOG_INFO("PCB= [id: %d, size: %lu, estimation: %d, program_counter: %d]", pcb->id, pcb->size, pcb->estimation, pcb->pc); \
}

// ============================================================================================================
// ***** Public Functions *****
// ============================================================================================================

pcb_t *receive_pcb(int fd)
{
ssize_t recv_bytes = -1;

pcb_t *pcb = NULL;
pcb = pcb_from_stream(servidor_recibir_stream(fd, &recv_bytes));
LOG_PCB(pcb);
return pcb;
}

0 comments on commit 60cf776

Please sign in to comment.