add kill + example code

scheduler.kill seems like its not implemented comletly or doest work as
expected.
This commit is contained in:
2025-12-03 07:07:34 +01:00
parent 9d1abb21f1
commit a50503e8c9
5 changed files with 34 additions and 53 deletions

View File

@@ -1,20 +1,7 @@
// vim: set noet ts=4 sw=4:
#include "appl.h"
#include "../../syscall/stub.h"
#include "../../arch/core.h"
#include "../../arch/system.h"
#include "../../debug/output.h"
#include "../../device/textstream.h"
#include "../../interrupt/guard.h"
#include "../../sync/semaphore.h"
#include "../../thread/scheduler.h"
extern Semaphore koutsem;
extern TextStream kout;
extern Application apps[];
void Application::action() { // NOLINT
// Thread 1 may be an auxiliary thread

View File

@@ -2,6 +2,7 @@
#include "./kappl.h"
#include "../../syscall/stub.h"
#include "../../utils/string.h"
#include "../../device/textstream.h"
extern TextStream kout;
@@ -9,49 +10,32 @@ extern TextStream kout;
extern Semaphore koutsem;
void KeyboardApplication::action() { // NOLINT
char cmd_buff[100];
uint8_t bufferpos = 0;
while(1){
char msg[11];
int len;
len = read(0, msg, 10);
if(len)
if(len){
write(0, msg, len);
memcpy(&cmd_buff[bufferpos], msg, len);
bufferpos+=len;
for(uint8_t i=0; i<len; i++)
if(msg[i] == '\n'){
bufferpos = 0;
if(strncmp(cmd_buff, "kill ", 5) == 0){
int pid = cmd_buff[5]-0x30;
char r[] = "killing X\n";
r[8] = pid+0x30;
write(0, r, 9);
sys_kill(pid);
}
if(strncmp(cmd_buff, "killall", 7) == 0){
for(uint8_t i = 0; i<10; i++){
sys_kill(i);
}
}
}
}
}
//const unsigned line = 10 + 2;
//for (unsigned column = 0;; ++column) {
// Key key;
// {
// Guarded g = Guard::enter();
// g.vault().keys_sem.p(g.vault());
// assert(g.vault().keys.consume(key) && "No key but sem returned!");
// }
// if (key.valid()) {
// if (column >= CGA::COLUMNS - 1) {
// column = 0;
// koutsem.p(Guard::enter().vault());
// for (unsigned offset = 0; offset < 3; offset++) {
// for (unsigned column = 0; column < CGA::COLUMNS; ++column) {
// CGA::show(column, line + offset, ' ');
// }
// }
// koutsem.v(Guard::enter().vault());
// }
// koutsem.p(Guard::enter().vault());
// kout.setPos(column, line);
// kout << static_cast<char>(key.ascii());
// kout.flush();
// koutsem.v(Guard::enter().vault());
// }
// for (unsigned offset = 0; offset < 3; offset++) {
// {
// Guarded g = Guard::enter();
// g.vault().bellringer.sleep(g.vault(), 10);
// koutsem.p(g.vault());
// }
// kout.setPos(column, line + offset);
// kout << static_cast<char>(key.ascii());
// kout.flush();
// koutsem.v(Guard::enter().vault());
// }
//}
}