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:
parent
9af7505421
commit
0041b86135
|
@ -35,15 +35,15 @@ int getTime(char option) {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
void wait(long seconds) {
|
void wait(long seconds) {
|
||||||
int initialSeconds = getTimeGen(SECONDS);
|
// int initialSeconds = getTimeGen(SECONDS);
|
||||||
int initialMinutes = getTimeGen(MINUTES);
|
// int initialMinutes = getTimeGen(MINUTES);
|
||||||
int runSeconds = 0;
|
// int runSeconds = 0;
|
||||||
if (initialSeconds + seconds >= 60) {
|
// if (initialSeconds + seconds >= 60) {
|
||||||
|
|
||||||
}
|
// }
|
||||||
int newSeconds = 0;
|
// int newSeconds = 0;
|
||||||
while ((newSeconds = getTimeGen(SECONDS) - initialSeconds) < seconds)
|
// while ((newSeconds = getTimeGen(SECONDS) - initialSeconds) < seconds)
|
||||||
haltcpu();
|
// haltcpu();
|
||||||
// while (initialSeconds - seconds != initialSeconds) {
|
// while (initialSeconds - seconds != initialSeconds) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
@ -55,7 +55,7 @@ static long getTimeFrom2000() {
|
||||||
long months = 1 * 2629800;
|
long months = 1 * 2629800;
|
||||||
long days = 1 * 86400;
|
long days = 1 * 86400;
|
||||||
|
|
||||||
long aux = years + months + days;
|
// long aux = years + months + days;
|
||||||
|
|
||||||
return years + months + days;
|
return years + months + days;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
|
||||||
static uint8_t * const video = (uint8_t *) 0xB8000;
|
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 width = 80;
|
||||||
static const int height = 25;
|
static const int height = 25;
|
||||||
static int currentX = 0;
|
static int currentX = 0;
|
||||||
|
|
|
@ -17,5 +17,6 @@ int getFdOut();
|
||||||
int getFdIn();
|
int getFdIn();
|
||||||
void checkSleeping();
|
void checkSleeping();
|
||||||
char unblockFirst(int pid);
|
char unblockFirst(int pid);
|
||||||
|
void sleep(int secs);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -20,5 +20,6 @@ sem_t * semOpen(char * name, unsigned int value);
|
||||||
char semClose(sem_t * sem);
|
char semClose(sem_t * sem);
|
||||||
void semWait(sem_t * sem);
|
void semWait(sem_t * sem);
|
||||||
void semPost(sem_t * sem);
|
void semPost(sem_t * sem);
|
||||||
|
char * getSems();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -20,24 +20,23 @@ uint64_t systemCallsDispatcher(uint64_t rdi, uint64_t rsi, uint64_t rdx, uint64_
|
||||||
case 2:
|
case 2:
|
||||||
return getTime(rsi, rdx, rcx);
|
return getTime(rsi, rdx, rcx);
|
||||||
case 3:
|
case 3:
|
||||||
return enqueueProcess(rsi, rdx, rcx, r8, r9);
|
return enqueueProcess((void (*)(int, char **)) rsi, rdx, rcx, (char **) r8, (int *) r9);
|
||||||
case 4:
|
case 4:
|
||||||
exitProcess();
|
exitProcess();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
// setFn(rsi, rdx, rcx);
|
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
return (uint64_t) processes();
|
return (uint64_t) processes();
|
||||||
case 7:
|
case 7:
|
||||||
return (uint64_t) getSems();
|
return (uint64_t) getSems();
|
||||||
case 8:
|
case 8:
|
||||||
return pvPortMalloc((size_t) rsi);
|
return (uint64_t) pvPortMalloc((size_t) rsi);
|
||||||
case 9:
|
case 9:
|
||||||
vPortFree((void *) rsi);
|
vPortFree((void *) rsi);
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
return (uint64_t) openPipe(rsi, rdx);
|
return (uint64_t) openPipe((int *) rsi, (char *) rdx);
|
||||||
case 11:
|
case 11:
|
||||||
return nice(rsi, rdx);
|
return nice(rsi, rdx);
|
||||||
case 12:
|
case 12:
|
||||||
|
@ -50,7 +49,7 @@ uint64_t systemCallsDispatcher(uint64_t rdi, uint64_t rsi, uint64_t rdx, uint64_
|
||||||
semPost((sem_t *) rsi);
|
semPost((sem_t *) rsi);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
return semOpen(rsi, rdx);
|
return (uint64_t) semOpen((char *) rsi, rdx);
|
||||||
case 16:
|
case 16:
|
||||||
kill(rsi);
|
kill(rsi);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -113,7 +113,7 @@ void strlen(const char *str, int *len) {
|
||||||
|
|
||||||
int strcpy(char * strDest, const char * strSrc) {
|
int strcpy(char * strDest, const char * strSrc) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (*strDest++ = *strSrc++) {
|
while ((*strDest++ = *strSrc++)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
// * the block. Small blocks at the start of the list and large blocks at the end
|
// * the block. Small blocks at the start of the list and large blocks at the end
|
||||||
// * of the list.
|
// * of the list.
|
||||||
// */
|
// */
|
||||||
|
/*
|
||||||
// #define prvInsertBlockIntoFreeList( pxBlockToInsert ) \
|
// #define prvInsertBlockIntoFreeList( pxBlockToInsert ) \
|
||||||
// { \
|
// { \
|
||||||
// BlockLink_t *pxIterator; \
|
// BlockLink_t *pxIterator; \
|
||||||
|
@ -85,18 +86,14 @@
|
||||||
// \
|
// \
|
||||||
// xBlockSize = pxBlockToInsert->xBlockSize; \
|
// 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 ) \
|
// 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; \
|
// pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock; \
|
||||||
// pxIterator->pxNextFreeBlock = pxBlockToInsert; \
|
// pxIterator->pxNextFreeBlock = pxBlockToInsert; \
|
||||||
// }
|
// }
|
||||||
|
*/
|
||||||
// /*-----------------------------------------------------------*/
|
// /*-----------------------------------------------------------*/
|
||||||
// void *pvPortMalloc( size_t xWantedSize )
|
// void *pvPortMalloc( size_t xWantedSize )
|
||||||
// {
|
// {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
// void _initialize_stack_frame(void *, void *, int, char**, void **, void **);
|
// void _initialize_stack_frame(void *, void *, int, char**, void **, void **);
|
||||||
// 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};
|
enum states {READY = 0, DEAD, BLOCKED};
|
||||||
|
|
||||||
|
@ -32,8 +32,6 @@ processCDT * firstBlockedIteration = NULL;
|
||||||
|
|
||||||
processCDT * firstProcess = NULL;
|
processCDT * firstProcess = NULL;
|
||||||
processCDT * lastProcess = NULL;
|
processCDT * lastProcess = NULL;
|
||||||
// processCDT * firstBlocked = NULL;
|
|
||||||
// processCDT * lastBlocked = NULL;
|
|
||||||
sleepCDT * firstSleep = NULL;
|
sleepCDT * firstSleep = NULL;
|
||||||
|
|
||||||
static processCDT * currentProcess = NULL;
|
static processCDT * currentProcess = NULL;
|
||||||
|
@ -100,58 +98,6 @@ uint64_t nextProcess(uint64_t currentRSP) {
|
||||||
return currentProcess->rsp;
|
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() {
|
void idle() {
|
||||||
while (1) {
|
while (1) {
|
||||||
haltcpu();
|
haltcpu();
|
||||||
|
|
|
@ -34,7 +34,7 @@ void bottler(int argc, char ** argv) {
|
||||||
printStringLen( " %%%%%%%%%%%%% ", 80); new_line();
|
printStringLen( " %%%%%%%%%%%%% ", 80); new_line();
|
||||||
printStringLen( " %%%%%%% ", 80); new_line();
|
printStringLen( " %%%%%%% ", 80); new_line();
|
||||||
printStringLen( " ", 80); new_line();
|
printStringLen( " ", 80); new_line();
|
||||||
// sys_sleep(3);
|
sys_sleep(3);
|
||||||
|
|
||||||
winClear();
|
winClear();
|
||||||
sys_exit();
|
sys_exit();
|
||||||
|
|
|
@ -33,7 +33,7 @@ char * strcat(char * dest, const char * src) {
|
||||||
|
|
||||||
while (*dest)
|
while (*dest)
|
||||||
dest++;
|
dest++;
|
||||||
while (*dest++ = *src++);
|
while ((*dest++ = *src++));
|
||||||
return rdest;
|
return rdest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void winClear() {
|
||||||
|
|
||||||
int strcpy(char * strDest, const char * strSrc) {
|
int strcpy(char * strDest, const char * strSrc) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (*strDest++ = *strSrc++) {
|
while ((*strDest++ = *strSrc++)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
char * argv1[] = {"bottler"};
|
char * argv1[] = {"bottler"};
|
||||||
sys_loadProcess(bottler, 1, 1, argv1, NULL);
|
sys_loadProcess(bottler, 1, 1, argv1, NULL);
|
||||||
// sys_sleep(4);
|
sys_sleep(4);
|
||||||
// winClear();
|
// winClear();
|
||||||
|
|
||||||
char * argv2[] = {"shell"};
|
char * argv2[] = {"shell"};
|
||||||
|
|
|
@ -2,17 +2,12 @@
|
||||||
#define PUAN -1
|
#define PUAN -1
|
||||||
|
|
||||||
void loop(int argc, char *argv[]) {
|
void loop(int argc, char *argv[]) {
|
||||||
// int pid = sys_getPid(), secs = atoi(argv[1], PUAN);
|
int pid = sys_getPid(), secs = atoi(argv[1], PUAN);
|
||||||
// char * str = "Hola, soy el proceso ";
|
char * str = "Hola, soy el proceso ";
|
||||||
// char buffer[MAX_LEN];
|
char buffer[MAX_PID_LEN];
|
||||||
// str = strcat(str, itoa(pid, buffer, 10));
|
str = strcat(str, itoa(pid, buffer, 10));
|
||||||
// while (1) {
|
while (1) {
|
||||||
// printString(str);
|
printString(str);
|
||||||
// sys_sleep(secs);
|
sys_sleep(secs);
|
||||||
// }
|
}
|
||||||
|
|
||||||
int pid = sys_getPid();
|
|
||||||
sys_block(pid);
|
|
||||||
sys_unblock(pid);
|
|
||||||
sys_exit();
|
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#define MAX_LEN 100
|
#define MAX_PID_LEN 100
|
||||||
|
|
||||||
void loop(int argc, char *argv[]);
|
void loop(int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue