diff --git a/Kernel/asm/interrupts.asm b/Kernel/asm/interrupts.asm index 1a3b141..ba1944e 100755 --- a/Kernel/asm/interrupts.asm +++ b/Kernel/asm/interrupts.asm @@ -28,7 +28,7 @@ EXTERN nextProcess GLOBAL switchContext GLOBAL loadProcess GLOBAL _initialize_stack_frame -GLOBAL _switchContext, forceTimerAux +;GLOBAL _switchContext, forceTimerAux EXTERN getFPUaddress, getSSEaddress EXTERN checkSleeping @@ -173,110 +173,46 @@ picSlaveMask: pop rbp retn -; getFPUaddress: -; push rcx -; mov ecx, [auxi] -; mov ecx, 1 -; xor ecx, [auxi] -; cmp ecx, 0 -; jne .getSecond -; mov rax, bytesForFPU1 -; jmp .finish -; .getSecond: -; mov rax, bytesForFPU2 -; .finish: -; mov dword [auxi], ecx -; pop rcx -; ret - -; getSSEaddress: -; push rcx -; mov ecx, [auxi] -; cmp ecx, 0 -; jne .getSecond -; mov rax, bytesForSSEAligned1 -; jmp .finish -; .getSecond: -; mov rax, bytesForSSEAligned2 -; .finish: -; pop rcx -; ret - -forceTimerAux: - pushStateNoRax - - ; call checkSleeping - - call nextProcess - mov rsp, rax - - popStateNoRax - iretq - ;8254 Timer (Timer Tick) _irq00Handler: pushState - ; mov rsi, rsp - ; and rsp, -16 - ; sub rsp, 108 - ; fsave [rsp] - ; and rsp, -16 - ; sub rsp, 512 - ; fxsave [rsp] - ; push rsi - - ; push rax - ; call getFPUaddress - ; fsave [rax] - ; call getSSEaddress - ; fxsave [rax] - ; pop rax - ; fsave [bytesForFPU] - ; fxsave [bytesForSSEAligned] + mov rsi, rsp + and rsp, -16 + sub rsp, 108 + fsave [rsp] + and rsp, -16 + sub rsp, 512 + fxsave [rsp] + push rsi call checkSleeping - mov rdi, rsp - call updateRSP - mov r10, rax + ; mov rdi, rsp + ; call updateRSP mov rdi, 0 call irqDispatcher + mov rdi, rsp call nextProcess mov rsp, rax mov al, 20h out 20h, al - ; fxrstor [bytesForSSEAligned] - ; frstor [bytesForFPU] - ; push rax - ; call getFPUaddress - ; frstor [rax] - ; call getSSEaddress - ; fxrstor [rax] - ; pop rax - - ; cmp r10, 0 - ; je .end - - ; pop rsp - ; mov rax, rsp - ; and rsp, -16 - ; sub rsp, 108 - ; frstor [rsp] - ; and rsp, -16 - ; sub rsp, 512 - ; fxrstor [rsp] - ; mov rsp, rax + pop rsp + mov rax, rsp + and rsp, -16 + sub rsp, 108 + frstor [rsp] + and rsp, -16 + sub rsp, 512 + fxrstor [rsp] + mov rsp, rax popState iretq -; .end: -; popStateNoRax -; iretq ;Keyboard _irq01Handler: @@ -312,7 +248,6 @@ haltcpu: cli ret - _initialize_stack_frame: mov r10, rsp mov rsp, rsi @@ -328,28 +263,15 @@ _initialize_stack_frame: pushState - ; mov rsi, rsp - ; and rsp, -16 - ; sub rsp, 108 - ; fsave [rsp] - ; and rsp, -16 - ; sub rsp, 512 - ; fxsave [rsp] - ; push rsi - ; mov rax, rsp - - ; fsave [bytesForFPU] - ; fxsave [bytesForSSEAligned] - - ; push rax - ; call getFPUaddress - ; fsave [rax] - ; call getSSEaddress - ; fxsave [rax] - ; pop rax - - ; fsave [r8] - ; fxsave [r9] + mov rsi, rsp + and rsp, -16 + sub rsp, 108 + fsave [rsp] + and rsp, -16 + sub rsp, 512 + fxsave [rsp] + push rsi + mov rax, rsp mov rsp, r10 ret @@ -359,36 +281,34 @@ _systemCallsHandler: pushStateNoRax ; fsave [bytesForFPU] ; fxsave [bytesForSSEAligned] - ; mov [auxRSI], rsi - ; mov rsi, rsp - ; and rsp, -16 - ; sub rsp, 108 - ; fsave [rsp] - ; and rsp, -16 - ; sub rsp, 512 - ; fxsave [rsp] - ; push rsi - ; mov [auxRDI], rdi - ; mov rdi, rsp - ; call updateRSP + mov [auxRSI], rsi + mov rsi, rsp + and rsp, -16 + sub rsp, 108 + fsave [rsp] + and rsp, -16 + sub rsp, 512 + fxsave [rsp] + push rsi + mov rsi, [auxRSI] - ; mov rsi, [auxRSI] - ; mov rdi, [auxRDI] call systemCallsDispatcher ; fxrstor [bytesForSSEAligned] ; frstor [bytesForFPU] - ; pop rsp - ; mov rax, rsp - ; and rsp, -16 - ; sub rsp, 108 - ; frstor [rsp] - ; and rsp, -16 - ; sub rsp, 512 - ; fxrstor [rsp] - ; mov rsp, rax + pop rsp + mov [auxRAX], rax + mov rax, rsp + and rsp, -16 + sub rsp, 108 + frstor [rsp] + and rsp, -16 + sub rsp, 512 + fxrstor [rsp] + mov rsp, rax + mov rax, [auxRAX] popStateNoRax iretq @@ -396,18 +316,13 @@ _systemCallsHandler: SECTION .data align 16 bytesForSSEAligned times 512 db 0 - ; bytesForSSEAligned1 times 512 db 0 - ; bytesForSSEAligned2 times 512 db 0 - ; counter dd 1 SECTION .bss aux resq 1 bytesForSSE resb 512 bytesForFPU resb 108 - ; bytesForFPU1 resb 108 - ; bytesForFPU2 resb 108 insPointer resb 8 rspPointer resb 8 auxRSI resb 8 auxRDI resb 8 - ; auxi resb 4 \ No newline at end of file + auxRAX resb 8 \ No newline at end of file diff --git a/Kernel/kernel.c b/Kernel/kernel.c index a640d08..15b87d3 100644 --- a/Kernel/kernel.c +++ b/Kernel/kernel.c @@ -181,7 +181,7 @@ int main() { clear(); // haltcpu(); _sti(); - // forceTimer(); + forceTimer(); // printBottlerAndWait(); return EXIT_SUCCESS; diff --git a/Kernel/loader.asm b/Kernel/loader.asm index 52799bc..98c538e 100644 --- a/Kernel/loader.asm +++ b/Kernel/loader.asm @@ -7,7 +7,7 @@ loader: mov rsp, rax ; Set up the stack with the returned address call main -; hang: -; cli -; hlt ; halt machine should kernel return -; jmp hang +hang: + cli + hlt ; halt machine should kernel return + jmp hang diff --git a/Kernel/utils/scheduler.c b/Kernel/utils/scheduler.c index f04f7b8..61cb16f 100644 --- a/Kernel/utils/scheduler.c +++ b/Kernel/utils/scheduler.c @@ -5,19 +5,7 @@ // void _initialize_stack_frame(void *, void *, int, char**, void *, void *); uint64_t * _initialize_stack_frame(void *, void *, int, char**); -enum states {READY = 0, BLOCKED}; - -// typedef long Align; - -// union header { -// struct { -// void * fpuBytes; -// void * sseBytes; -// } s; -// Align x; -// }; - -// typedef union header Header; +enum states {READY = 0, DEAD, BLOCKED}; typedef struct processCDT { struct processCDT * next; @@ -31,10 +19,6 @@ typedef struct processCDT { char foreground; enum states state; int * fd; - // Header * bytes; - // Header * sse; - // void * sseBytes; - // void * fpuBytes; } processCDT; typedef struct sleepCDT { @@ -44,29 +28,12 @@ typedef struct sleepCDT { struct sleepCDT * next; } sleepCDT; -// typedef union processCDT { -// struct { -// struct p * next; -// char * name; -// int pid; -// int ppid; -// uint64_t rsp; -// uint64_t rbp; -// char priority; -// char executions; -// char foreground; -// enum states state; -// int * fd; -// void * sseBytes; -// void * fpuBytes; -// } p; -// Align x; -// } processCDT; +processCDT * firstBlockedIteration = NULL; -processCDT * firstReady = NULL; -processCDT * lastReady = NULL; -processCDT * firstBlocked = NULL; -processCDT * lastBlocked = NULL; +processCDT * firstProcess = NULL; +processCDT * lastProcess = NULL; +// processCDT * firstBlocked = NULL; +// processCDT * lastBlocked = NULL; sleepCDT * firstSleep = NULL; static processCDT * currentProcess = NULL; @@ -74,17 +41,103 @@ static int pids = IDLE_PID; static char update = 1; static char idleFlag = 2; -uint64_t nextProcess() { +void debug() { + return; +} + +void removeProcess(processCDT * del, processCDT * prev, processCDT ** first, processCDT ** last) { + if (prev == NULL) { + *first = del->next; + if (*last == del) + *last = NULL; + } + else { + prev->next = del->next; + if (*last == del) + *last = prev; + } +} + +uint64_t nextProcess(uint64_t currentRSP) { + if (currentProcess != NULL /*&& currentProcess->state != BLOCKED*/) + currentProcess->rsp = currentRSP; + processCDT * prev = currentProcess; + if (currentProcess != NULL) + currentProcess = currentProcess->next; + while (currentProcess == NULL || currentProcess->state == BLOCKED || currentProcess->state == DEAD) { + if (currentProcess == NULL) { + currentProcess = firstProcess; + } + else if (currentProcess == firstBlockedIteration) { + idleFlag = 2; + unblock(IDLE_PID); + prev = currentProcess; + currentProcess = currentProcess->next; + } + else if (currentProcess->state == DEAD) { + debug(); + processCDT * del = currentProcess; + currentProcess = currentProcess->next; + removeProcess(del, prev, &firstProcess, &lastProcess); + vPortFree((void *) del); + } + else if (currentProcess->state == BLOCKED) { + if (firstBlockedIteration == NULL) + firstBlockedIteration = currentProcess; + prev = currentProcess; + currentProcess = currentProcess->next; + } + else if (currentProcess->state == READY && currentProcess->executions == MAX_PRIORITY - currentProcess->priority + 1) { + currentProcess->executions = 0; + prev = currentProcess; + currentProcess = currentProcess->next; + } + } + if (currentProcess->pid != IDLE_PID) + block(IDLE_PID); + firstBlockedIteration = NULL; + currentProcess->executions++; + return currentProcess->rsp; +} + +/* +uint64_t nextProcess(uint64_t currentRSP) { + if (currentProcess == firstBlockedIteration) { + idleFlag = 2; + unblock(IDLE_PID); + } update = 1; if (currentProcess == NULL) { - if (firstReady == 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); } - - currentProcess = firstReady; - return firstReady->rsp; + else currentProcess = firstProcess; + return currentProcess->rsp; } + firstBlockedIteration = NULL; if (currentProcess->executions < MAX_PRIORITY - currentProcess->priority + 1) { currentProcess->executions++; return currentProcess->rsp; @@ -93,10 +146,11 @@ uint64_t nextProcess() { if (currentProcess->next != NULL) currentProcess = currentProcess->next; else { - currentProcess = firstReady; + currentProcess = firstProcess; } return currentProcess->rsp; } +*/ void idle() { while (1) { @@ -106,15 +160,9 @@ void idle() { void initScheduler() { char * argv[] = {"idle"}; - enqueueProcess(idle, 0, 1, argv, NULL); + nice(enqueueProcess(idle, 0, 1, argv, NULL), 19); } -// void setFn(void (*fn) (int, char **), int argc, char *argv[]) { -// currentProcess->rsp = (currentProcess->rbp) - 20; - // _initialize_stack_frame(fn, currentProcess->rbp, argc, argv); -// } - -// void enqueueProcess(void (*fn) (int, char **), char foreground, int argc, char *argv[]) { int enqueueProcess(void (*fn) (int, char **), char foreground, int argc, char *argv[], int * fd) { if (fd == NULL) { int * aux = pvPortMalloc(2 * sizeof(int)); @@ -122,7 +170,7 @@ int enqueueProcess(void (*fn) (int, char **), char foreground, int argc, char *a aux[1] = 1; fd = aux; } - if (firstReady != NULL && firstReady->pid == IDLE_PID) + if (!idleFlag) block(IDLE_PID); processADT process = pvPortMalloc(sizeof(processCDT)); @@ -151,39 +199,19 @@ int enqueueProcess(void (*fn) (int, char **), char foreground, int argc, char *a process->state = READY; process->fd = fd; process->next = NULL; - // process->bytes->s.fpuBytes = pvPortMalloc(108); - // process->bytes->s.sseBytes = pvPortMalloc(512); - // process->sseBytes = pvPortMalloc(64); - // process->fpuBytes = pvPortMalloc(14); - // _initialize_stack_frame(fn, rbp, argc, argv, &(process->fpuBytes), &(process->sseBytes)); - // _initialize_stack_frame(fn, rbp, argc, argv, &(process->bytes->s.sseBytes), &(process->bytes->s.fpuBytes)); - // _initialize_stack_frame(fn, rbp, argc, argv, process->bytes->s.sseBytes, process->bytes->s.fpuBytes); - // process->rsp = _initialize_stack_frame(fn, rbp, argc, argv); - _initialize_stack_frame(fn, rbp, argc, argv); + process->rsp = _initialize_stack_frame(fn, rbp, argc, argv); + // _initialize_stack_frame(fn, rbp, argc, argv); - if (firstReady == NULL) - firstReady = process; + if (firstProcess == NULL) + firstProcess = process; else - lastReady->next = process; - lastReady = process; + lastProcess->next = process; + lastProcess = process; return process->pid; } -void removeProcess(processCDT * del, processCDT * prev, processCDT ** first, processCDT ** last) { - if (prev == NULL) { - *first = del->next; - if (*last == del) - *last = NULL; - } - else { - prev->next = del->next; - if (*last == del) - *last = prev; - } -} - void sleep(int secs) { if (currentProcess == NULL) return; @@ -204,7 +232,7 @@ void wakeUp(sleepCDT * wake, sleepCDT * prev) { else { prev->next = wake->next; } - unblockFirst(wake->pid); + unblock(wake->pid); vPortFree(wake); } @@ -255,11 +283,13 @@ processADT searchProcess(processADT * previous, int pid, processADT first) { char block(int pid) { processADT prev = NULL; - processADT del = searchProcess(&prev, pid, firstReady); + processADT del = searchProcess(&prev, pid, firstProcess); if (del == NULL) return EXIT_FAILURE; else { - removeProcess(del, prev, &firstReady, &lastReady); + // removeProcess(del, prev, &firstReady, &lastReady); + del->state = BLOCKED; + //blockProcess(del, prev); // if (prev != NULL) { // prev->next = del->next; // if (lastReady == del) @@ -272,31 +302,45 @@ char block(int pid) { // } } - processCDT * next = del->next; - del->next = NULL; + // processCDT * next = del->next; + // del->next = NULL; - if (lastBlocked != NULL) - lastBlocked->next = del; - else - firstBlocked = del; - lastBlocked = del; + // del->state = BLOCKED; + // if (lastBlocked != NULL) + // lastBlocked->next = del; + // else + // firstBlocked = del; + // lastBlocked = del; + + // processCDT * auxCurr = pvPortMalloc(sizeof(processCDT)); + // auxCurr->next = next; + // auxCurr->pid = pid; + // currentProcess->state = BLOCKED; if (pid == currentProcess->pid) { - update = 0; - currentProcess = next; + // update = 0; + // currentProcess = next; + forceTimer(); } return EXIT_SUCCESS; } +// void debug() { +// return; +// } + char unblock(int pid) { processADT prev = NULL; - processADT del = searchProcess(&prev, pid, firstBlocked); - if (del == NULL) + processADT del = searchProcess(&prev, pid, firstProcess); + if (del == NULL) { + // debug(); return EXIT_FAILURE; + } else { - removeProcess(del, prev, &firstBlocked, &lastBlocked); + // removeProcess(del, prev, &firstBlocked, &lastBlocked); + del->state = READY; // if (prev != NULL) { // prev->next = del->next; // if (del == lastBlocked) @@ -309,13 +353,14 @@ char unblock(int pid) { // } } - del->next = NULL; - if (lastReady != NULL) - lastReady->next = del; - else - firstReady = del; - lastReady = del; - + // del->next = NULL; + // if (lastReady != NULL) + // lastReady->next = del; + // else + // firstReady = del; + // lastReady = del; +// + // del->state = READY; // if (firstReady != NULL && firstReady->pid == IDLE_PID && lastReady->pid != IDLE_PID) if (idleFlag && !(--idleFlag)) block(IDLE_PID); @@ -323,13 +368,15 @@ char unblock(int pid) { return EXIT_SUCCESS; } +/* char unblockFirst(int pid) { processADT prev = NULL; processADT del = searchProcess(&prev, pid, firstBlocked); if (del == NULL) return EXIT_FAILURE; else { - removeProcess(del, prev, &firstBlocked, &lastBlocked); + // removeProcess(del, prev, &firstBlocked, &lastBlocked); + // if (prev != NULL) { // prev->next = del->next; // if (lastBlocked == del) @@ -357,33 +404,36 @@ char unblockFirst(int pid) { lastReady = del; } + del->state = READY; + // if (firstReady != NULL && lastReady->pid == IDLE_PID && firstReady->pid != IDLE_PID) if (idleFlag && !(--idleFlag)) block(IDLE_PID); return EXIT_SUCCESS; } +*/ char kill(int pid) { processADT prev = NULL; - processADT del = searchProcess(&prev, pid, firstReady); + processADT del = searchProcess(&prev, pid, firstProcess); if (del == NULL) { - del = searchProcess(&prev, pid, firstBlocked); - if (del == NULL) + // del = searchProcess(&prev, pid, firstBlocked); + // if (del == NULL) return EXIT_FAILURE; - else { - removeProcess(del, prev, &firstBlocked, &lastBlocked); - // if (prev != NULL) { - // prev->next = del->next; - // if (del == lastBlocked) - // lastBlocked = prev; - // } - // else - // firstBlocked = del->next; - } + // else { + // removeProcess(del, prev, &firstBlocked, &lastBlocked); + // // if (prev != NULL) { + // // prev->next = del->next; + // // if (del == lastBlocked) + // // lastBlocked = prev; + // // } + // // else + // // firstBlocked = del->next; + // } } - else { - removeProcess(del, prev, &firstReady, &lastReady); + // else { + // removeProcess(del, prev, &firstReady, &lastReady); // if (prev != NULL) { // prev->next = del->next; // if (del == lastReady) @@ -391,17 +441,19 @@ char kill(int pid) { // } // else // firstReady = del->next; - } + // } - processCDT * next = del->next; + // processCDT * next = del->next; vPortFree(del->fd); vPortFree((void *) del->rbp - STACK_SIZE); - vPortFree((void *) del); + currentProcess->state = DEAD; if (pid == currentProcess->pid) { - update = 0; - currentProcess = next; + // if (pid < 9) + // update = 0; + // currentProcess = next; + forceTimer(); } @@ -429,13 +481,13 @@ char nice(int pid, char offset) { return EXIT_FAILURE; processADT prev = NULL; - processADT del = searchProcess(&prev, pid, firstReady); + processADT del = searchProcess(&prev, pid, firstProcess); if (del == NULL) { - del = searchProcess(&prev, pid, firstBlocked); - if (del == NULL) + // del = searchProcess(&prev, pid, firstBlocked); + // if (del == NULL) return EXIT_FAILURE; - else - del->priority = offset + 20; + // else + // del->priority = offset + 20; } else { del->priority = offset + 20; @@ -503,7 +555,8 @@ char getProcessData(char * out, processCDT * proc) { getGenProcessData(&out, &written, MAX_ATTR_SIZE, itoa(proc->priority, buffer, 10, 2), 0); getGenProcessData(&out, &written, MAX_NAME_SIZE, itoa(proc->rsp, buffer, 16, 10), 0); getGenProcessData(&out, &written, MAX_NAME_SIZE, itoa(proc->rbp, buffer, 16, 10), 0); - getGenProcessData(&out, &written, MAX_ATTR_SIZE, (proc->foreground == 1) ? "F" : "B", 1); + getGenProcessData(&out, &written, MAX_ATTR_SIZE, (proc->foreground == 1) ? "F" : "B", 0); + getGenProcessData(&out, &written, MAX_ATTR_SIZE, proc->state == BLOCKED ? "Block" : proc->state == DEAD ? "Killed" : "Ready", 1); return written; } @@ -512,24 +565,18 @@ char * processes(){ char * ans = pvPortMalloc(pids * PROCESS_DATA_MAX_SIZE); char * ret = ans; - char * info = "name pid prio rsp rbp fore\n"; + char * info = "name pid prio rsp rbp fore state\n"; ans += strcpy(ans, info); // ans += 56; - processCDT * aux = firstReady; + processCDT * aux = firstProcess; while (aux != NULL) { char writtenChars = getProcessData(ans, aux); if (writtenChars == EXIT_FAILURE) return NULL; ans += writtenChars - 1; *ans++ = '\n'; - - if (aux == lastBlocked) - aux = NULL; - else if (aux == lastReady) - aux = firstBlocked; - else - aux = aux->next; + aux = aux->next; } *--ans = 0; diff --git a/Kernel/utils/sem.c b/Kernel/utils/sem.c index 2f26b6a..ee445a9 100644 --- a/Kernel/utils/sem.c +++ b/Kernel/utils/sem.c @@ -106,10 +106,12 @@ void semPost(sem_t * sem) { sem->value++; - pid_t * aux = sem->entering; - sem->entering = sem->entering->next; - unblock(sem->entering->pid); - vPortFree(aux); + if (sem->entering != NULL) { + pid_t * aux = sem->entering; + sem->entering = sem->entering->next; + unblock(sem->entering->pid); + vPortFree(aux); + } leave_region(&semLock); } diff --git a/Userland/SampleCodeModule/sampleCodeModule.c b/Userland/SampleCodeModule/sampleCodeModule.c index bcff4f5..ad88b9f 100644 --- a/Userland/SampleCodeModule/sampleCodeModule.c +++ b/Userland/SampleCodeModule/sampleCodeModule.c @@ -14,6 +14,7 @@ int main(int argc, char *argv[]) { char * argv1[] = {"bottler"}; sys_loadProcess(bottler, 1, 1, argv1, NULL); // sys_sleep(4); + // winClear(); char * argv2[] = {"shell"}; sys_loadProcess(shell, 1, 1, argv2, NULL); diff --git a/Userland/SampleCodeModule/shell/commands/loop.c b/Userland/SampleCodeModule/shell/commands/loop.c index 5cd882c..1f3367e 100644 --- a/Userland/SampleCodeModule/shell/commands/loop.c +++ b/Userland/SampleCodeModule/shell/commands/loop.c @@ -2,12 +2,17 @@ #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(), 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(); } \ No newline at end of file diff --git a/Userland/SampleCodeModule/shell/commands/phylo.c b/Userland/SampleCodeModule/shell/commands/phylo.c index 8900f80..b9870a8 100644 --- a/Userland/SampleCodeModule/shell/commands/phylo.c +++ b/Userland/SampleCodeModule/shell/commands/phylo.c @@ -201,31 +201,30 @@ void phylo(int argc, char ** argv) { phil = phil->right; } while (phil != firstPhil); - // char c; - // while (1) { - // while ((c = getChar()) != 0 && c != -1) { - // if (c == 'a') { - // addPhilo(); - // } - // else if (c == 'r') { - // removePhilo(); - // } - // else if (c == 'q') { - // break; - // } - // } - // } + //char c; + //while (1) { + // while ((c = getChar()) != 0 && c != -1) { + // if (c == 'a') { + // addPhilo(); + // } + // else if (c == 'r') { + // removePhilo(); + // } + // else if (c == 'q') { + // break; + // } + // } + //} - // phil = firstPhil; - // do { - // sys_semClose(phil); - // sys_free(phil); - // sys_free(phil); - // sys_free(phil); - - // sys_kill(phil->pid); - // phil = phil->right; - // } while (phil != firstPhil); // PROBLEMA + //phil = firstPhil; + //do { + // sys_semClose(phil); + // sys_free(phil); + // sys_free(phil); + // sys_free(phil); + // sys_kill(phil->pid); + // phil = phil->right; + //} while (phil != firstPhil); // PROBLEMA sys_exit(); } diff --git a/Userland/SampleCodeModule/shell/shell.c b/Userland/SampleCodeModule/shell/shell.c index 102161a..1d3cc20 100644 --- a/Userland/SampleCodeModule/shell/shell.c +++ b/Userland/SampleCodeModule/shell/shell.c @@ -20,6 +20,7 @@ #include "kill.h" #include "block.h" #include "unblock.h" +#include "loop.h" #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 @@ -55,6 +56,7 @@ cmd_t commands[] = { { "printmem", printmem, 0 }, { "phylo", phylo, 0 }, { "wc", wc, 0 }, + { "loop", loop, 0 }, { NULL, NULL, 0} };