Fix ALL bugs and remove compilation warnings

Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar>
Co-authored-by: Juan Barmasch <jbarmasch@itba.edu.ar>
This commit is contained in:
Santiago Lo Coco 2021-10-30 08:28:03 -03:00
parent 9af7505421
commit 0041b86135
13 changed files with 33 additions and 94 deletions

View File

@ -35,15 +35,15 @@ int getTime(char option) {
// TODO
void wait(long seconds) {
int initialSeconds = getTimeGen(SECONDS);
int initialMinutes = getTimeGen(MINUTES);
int runSeconds = 0;
if (initialSeconds + seconds >= 60) {
// int initialSeconds = getTimeGen(SECONDS);
// int initialMinutes = getTimeGen(MINUTES);
// int runSeconds = 0;
// if (initialSeconds + seconds >= 60) {
}
int newSeconds = 0;
while ((newSeconds = getTimeGen(SECONDS) - initialSeconds) < seconds)
haltcpu();
// }
// int newSeconds = 0;
// while ((newSeconds = getTimeGen(SECONDS) - initialSeconds) < seconds)
// haltcpu();
// while (initialSeconds - seconds != initialSeconds) {
// }
@ -55,7 +55,7 @@ static long getTimeFrom2000() {
long months = 1 * 2629800;
long days = 1 * 86400;
long aux = years + months + days;
// long aux = years + months + days;
return years + months + days;
}

View File

@ -2,7 +2,7 @@
#include "video.h"
static uint8_t * const video = (uint8_t *) 0xB8000;
static uint8_t * currentVideo = (uint8_t *) 0xB8000;
// static uint8_t * currentVideo = (uint8_t *) 0xB8000;
static const int width = 80;
static const int height = 25;
static int currentX = 0;

View File

@ -17,5 +17,6 @@ int getFdOut();
int getFdIn();
void checkSleeping();
char unblockFirst(int pid);
void sleep(int secs);
#endif

View File

@ -20,5 +20,6 @@ sem_t * semOpen(char * name, unsigned int value);
char semClose(sem_t * sem);
void semWait(sem_t * sem);
void semPost(sem_t * sem);
char * getSems();
#endif

View File

@ -20,24 +20,23 @@ uint64_t systemCallsDispatcher(uint64_t rdi, uint64_t rsi, uint64_t rdx, uint64_
case 2:
return getTime(rsi, rdx, rcx);
case 3:
return enqueueProcess(rsi, rdx, rcx, r8, r9);
return enqueueProcess((void (*)(int, char **)) rsi, rdx, rcx, (char **) r8, (int *) r9);
case 4:
exitProcess();
break;
case 5:
// setFn(rsi, rdx, rcx);
break;
case 6:
return (uint64_t) processes();
case 7:
return (uint64_t) getSems();
case 8:
return pvPortMalloc((size_t) rsi);
return (uint64_t) pvPortMalloc((size_t) rsi);
case 9:
vPortFree((void *) rsi);
break;
case 10:
return (uint64_t) openPipe(rsi, rdx);
return (uint64_t) openPipe((int *) rsi, (char *) rdx);
case 11:
return nice(rsi, rdx);
case 12:
@ -50,7 +49,7 @@ uint64_t systemCallsDispatcher(uint64_t rdi, uint64_t rsi, uint64_t rdx, uint64_
semPost((sem_t *) rsi);
break;
case 15:
return semOpen(rsi, rdx);
return (uint64_t) semOpen((char *) rsi, rdx);
case 16:
kill(rsi);
break;

View File

@ -113,7 +113,7 @@ void strlen(const char *str, int *len) {
int strcpy(char * strDest, const char * strSrc) {
int i = 0;
while (*strDest++ = *strSrc++) {
while ((*strDest++ = *strSrc++)) {
i++;
}
return i;

View File

@ -78,6 +78,7 @@
// * the block. Small blocks at the start of the list and large blocks at the end
// * of the list.
// */
/*
// #define prvInsertBlockIntoFreeList( pxBlockToInsert ) \
// { \
// BlockLink_t *pxIterator; \
@ -85,18 +86,14 @@
// \
// xBlockSize = pxBlockToInsert->xBlockSize; \
// \
// /* Iterate through the list until a block is found that has a larger size */ \
// /* than the block we are inserting. */ \
// for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIterator->pxNextFreeBlock ) \
// { \
// /* There is nothing to do here - just iterate to the correct position. */ \
// } \
// \
// /* Update the list to include the block being inserted in the correct */ \
// /* position. */ \
// pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \
// pxIterator->pxNextFreeBlock = pxBlockToInsert; \
// }
*/
// /*-----------------------------------------------------------*/
// void *pvPortMalloc( size_t xWantedSize )
// {

View File

@ -3,7 +3,7 @@
// void _initialize_stack_frame(void *, void *, int, char**, void **, void **);
// void _initialize_stack_frame(void *, void *, int, char**, void *, void *);
uint64_t * _initialize_stack_frame(void *, void *, int, char**);
uint64_t _initialize_stack_frame(void *, void *, int, char**);
enum states {READY = 0, DEAD, BLOCKED};
@ -32,8 +32,6 @@ processCDT * firstBlockedIteration = NULL;
processCDT * firstProcess = NULL;
processCDT * lastProcess = NULL;
// processCDT * firstBlocked = NULL;
// processCDT * lastBlocked = NULL;
sleepCDT * firstSleep = NULL;
static processCDT * currentProcess = NULL;
@ -100,58 +98,6 @@ uint64_t nextProcess(uint64_t currentRSP) {
return currentProcess->rsp;
}
/*
uint64_t nextProcess(uint64_t currentRSP) {
if (currentProcess == firstBlockedIteration) {
idleFlag = 2;
unblock(IDLE_PID);
}
update = 1;
if (currentProcess == NULL) {
currentProcess = firstProcess;
return currentProcess->rsp;
}
else if (currentProcess->state == DEAD) {
processCDT * del = currentProcess;
if (currentProcess->next != NULL) {
currentProcess = currentProcess->next;
}
else currentProcess = firstProcess;
processCDT * prev = NULL;
removeProcess(del, prev, &firstProcess, &lastProcess);
vPortFree((void *) del);
return currentProcess->rsp;
}
currentProcess->rsp = currentRSP;
if (currentProcess->state == BLOCKED) {
if (firstBlockedIteration == NULL)
firstBlockedIteration = currentProcess;
processCDT * del = currentProcess;
if (currentProcess->next != NULL) {
currentProcess = currentProcess->next;
}
else if (firstProcess == NULL) {
idleFlag = 2;
unblock(IDLE_PID);
}
else currentProcess = firstProcess;
return currentProcess->rsp;
}
firstBlockedIteration = NULL;
if (currentProcess->executions < MAX_PRIORITY - currentProcess->priority + 1) {
currentProcess->executions++;
return currentProcess->rsp;
}
currentProcess->executions = 0;
if (currentProcess->next != NULL)
currentProcess = currentProcess->next;
else {
currentProcess = firstProcess;
}
return currentProcess->rsp;
}
*/
void idle() {
while (1) {
haltcpu();

View File

@ -34,7 +34,7 @@ void bottler(int argc, char ** argv) {
printStringLen( " %%%%%%%%%%%%% ", 80); new_line();
printStringLen( " %%%%%%% ", 80); new_line();
printStringLen( " ", 80); new_line();
// sys_sleep(3);
sys_sleep(3);
winClear();
sys_exit();

View File

@ -33,7 +33,7 @@ char * strcat(char * dest, const char * src) {
while (*dest)
dest++;
while (*dest++ = *src++);
while ((*dest++ = *src++));
return rdest;
}
@ -56,7 +56,7 @@ void winClear() {
int strcpy(char * strDest, const char * strSrc) {
int i = 0;
while (*strDest++ = *strSrc++) {
while ((*strDest++ = *strSrc++)) {
i++;
}
return i;

View File

@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
char * argv1[] = {"bottler"};
sys_loadProcess(bottler, 1, 1, argv1, NULL);
// sys_sleep(4);
sys_sleep(4);
// winClear();
char * argv2[] = {"shell"};

View File

@ -2,17 +2,12 @@
#define PUAN -1
void loop(int argc, char *argv[]) {
// int pid = sys_getPid(), secs = atoi(argv[1], PUAN);
// char * str = "Hola, soy el proceso ";
// char buffer[MAX_LEN];
// str = strcat(str, itoa(pid, buffer, 10));
// while (1) {
// printString(str);
// sys_sleep(secs);
// }
int pid = sys_getPid();
sys_block(pid);
sys_unblock(pid);
sys_exit();
int pid = sys_getPid(), secs = atoi(argv[1], PUAN);
char * str = "Hola, soy el proceso ";
char buffer[MAX_PID_LEN];
str = strcat(str, itoa(pid, buffer, 10));
while (1) {
printString(str);
sys_sleep(secs);
}
}

View File

@ -4,7 +4,7 @@
#include "libc.h"
#include "system.h"
#define MAX_LEN 100
#define MAX_PID_LEN 100
void loop(int argc, char *argv[]);