diff --git a/Kernel/drivers/time.c b/Kernel/drivers/time.c index f4adc66..9b85a6c 100755 --- a/Kernel/drivers/time.c +++ b/Kernel/drivers/time.c @@ -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; } diff --git a/Kernel/drivers/video.c b/Kernel/drivers/video.c index e40d27c..cc5811d 100644 --- a/Kernel/drivers/video.c +++ b/Kernel/drivers/video.c @@ -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; diff --git a/Kernel/include/schedulerLib.h b/Kernel/include/schedulerLib.h index 86b5e28..cc4daed 100644 --- a/Kernel/include/schedulerLib.h +++ b/Kernel/include/schedulerLib.h @@ -17,5 +17,6 @@ int getFdOut(); int getFdIn(); void checkSleeping(); char unblockFirst(int pid); +void sleep(int secs); #endif \ No newline at end of file diff --git a/Kernel/include/semLib.h b/Kernel/include/semLib.h index 0f26211..237d9c2 100644 --- a/Kernel/include/semLib.h +++ b/Kernel/include/semLib.h @@ -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 \ No newline at end of file diff --git a/Kernel/interruptions/systemCallsDispatcher.c b/Kernel/interruptions/systemCallsDispatcher.c index f464ef6..1778a4c 100644 --- a/Kernel/interruptions/systemCallsDispatcher.c +++ b/Kernel/interruptions/systemCallsDispatcher.c @@ -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; diff --git a/Kernel/lib.c b/Kernel/lib.c index 8b03e0e..f992436 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -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; diff --git a/Kernel/utils/memManagerFRT2.c b/Kernel/utils/memManagerFRT2.c index 4588472..3f54c15 100644 --- a/Kernel/utils/memManagerFRT2.c +++ b/Kernel/utils/memManagerFRT2.c @@ -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 ) // { diff --git a/Kernel/utils/scheduler.c b/Kernel/utils/scheduler.c index 61cb16f..b2e7a0c 100644 --- a/Kernel/utils/scheduler.c +++ b/Kernel/utils/scheduler.c @@ -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(); diff --git a/Userland/SampleCodeModule/bottler/bottler.c b/Userland/SampleCodeModule/bottler/bottler.c index d807b1e..c636651 100644 --- a/Userland/SampleCodeModule/bottler/bottler.c +++ b/Userland/SampleCodeModule/bottler/bottler.c @@ -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(); diff --git a/Userland/SampleCodeModule/libc.c b/Userland/SampleCodeModule/libc.c index a1f66bb..f274097 100644 --- a/Userland/SampleCodeModule/libc.c +++ b/Userland/SampleCodeModule/libc.c @@ -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; diff --git a/Userland/SampleCodeModule/sampleCodeModule.c b/Userland/SampleCodeModule/sampleCodeModule.c index ad88b9f..20210d8 100644 --- a/Userland/SampleCodeModule/sampleCodeModule.c +++ b/Userland/SampleCodeModule/sampleCodeModule.c @@ -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"}; diff --git a/Userland/SampleCodeModule/shell/commands/loop.c b/Userland/SampleCodeModule/shell/commands/loop.c index 1f3367e..e71ad6c 100644 --- a/Userland/SampleCodeModule/shell/commands/loop.c +++ b/Userland/SampleCodeModule/shell/commands/loop.c @@ -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); + } } \ No newline at end of file diff --git a/Userland/SampleCodeModule/shell/include/loop.h b/Userland/SampleCodeModule/shell/include/loop.h index 11252eb..b5c318c 100644 --- a/Userland/SampleCodeModule/shell/include/loop.h +++ b/Userland/SampleCodeModule/shell/include/loop.h @@ -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[]);