-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cpu): handle pcb from module CPU
- Loading branch information
1 parent
9e28760
commit 60cf776
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |