static void test_pqueue_peekmin_empty(void) { struct pqueue q; struct pqueue_node nodes[1]; struct pqueue_entry *min; bwputstr(COM2, "test_pqueue_peekmin_empty..."); pqueue_init(&q, ARRAY_SIZE(nodes), nodes); min = pqueue_peekmin(&q); assert(min == NULL); bwputstr(COM2, "ok\n"); }
static void test_pqueue_add_fail_val_oor(void) { struct pqueue q; struct pqueue_node nodes[1]; int rc; bwputstr(COM2, "test_pqueue_add_fail_val_oor..."); pqueue_init(&q, ARRAY_SIZE(nodes), nodes); rc = pqueue_add(&q, 1, 42); assert(rc == -1); rc = pqueue_add(&q, 2, 42); assert(rc == -1); bwputstr(COM2, "ok\n"); }
static void test_pqueue_add_fail_duplicate1(void) { struct pqueue q; struct pqueue_node nodes[2]; int rc; bwputstr(COM2, "test_pqueue_add_fail_duplicate1..."); pqueue_init(&q, ARRAY_SIZE(nodes), nodes); rc = pqueue_add(&q, 0, 42); assert(rc == 0); rc = pqueue_add(&q, 1, 3); assert(rc == 0); rc = pqueue_add(&q, 1, 55); assert(rc == -2); bwputstr(COM2, "ok\n"); }
static void test_pqueue_add_peekmin(void) { struct pqueue q; struct pqueue_node nodes[1]; struct pqueue_entry *min; int rc; bwputstr(COM2, "test_pqueue_add_peekmin..."); pqueue_init(&q, ARRAY_SIZE(nodes), nodes); rc = pqueue_add(&q, 0, 42); assert(rc == 0); min = pqueue_peekmin(&q); assert(min != NULL); assert(min->key == 42); assert(min->val == 0); bwputstr(COM2, "ok\n"); }
/* Will kind of suck without zero-padding */ void PrintBits(unsigned char *bits, int len) { int i; for(i = 0; i < len; ++i) { bwprintf(COM2, "%x-", bits[i]); } bwputstr(COM2, "\r\n"); }
static void test_pqueue_add2_popmin2_peekmin(void) { struct pqueue q; struct pqueue_node nodes[2]; struct pqueue_entry *min; int rc; bwputstr(COM2, "test_pqueue_add2_popmin2_peekmin..."); pqueue_init(&q, ARRAY_SIZE(nodes), nodes); rc = pqueue_add(&q, 0, 1); assert(rc == 0); rc = pqueue_add(&q, 1, 0); assert(rc == 0); pqueue_popmin(&q); pqueue_popmin(&q); min = pqueue_peekmin(&q); assert(min == NULL); bwputstr(COM2, "ok\n"); }
void fuckit() { int i; int tid = 0xB00B; char blah[20]; bwputstr(COM2, "FUCKIT: Going to recieve\r\n"); i = Receive(&tid, blah, 20); bwprintf(COM2, "FUCKIT:recv'd(%d) %s\r\n", i, blah); i = Reply(tid, "EAT MY ASS", 11); bwprintf(COM2, "FUCKIT: replyed %d. exiting. \r\n", i); Exit(); }
void first() { bwprintf (COM2, "I AM FIRST USER.\n\tMODE IS "); print_mode (); bwputstr (COM2, ".\n\tCREATE???\n"); //int z = Create (0xABCDEF01, (void*)0x10FEDCBA); int z = Create (3, second); int i=0,j=0,k=0; while (1) { bwprintf (COM2, "I AM FIRST USER.\n\tKERNEL SAID %d\n\tMODE IS ",z); print_mode (); bwputstr (COM2, ".\n\tPASS??\n"); i++; if (i>10) j++; if (j>10) k++; i %= 11; j %= 11; // bwprintf (COM2, "(i,j,k) = (%d,%d,%d)\n",i,j,k); Pass(); bwprintf (COM2, "I AM FIRST USER.\n\tMODE IS "); print_mode (); bwputstr (COM2, ".\n\tEXIT????\n"); Exit(); } // int i = 0xFFFFF; int r; while (i--) { bwprintf(COM2, "Hey, I'm a user(%d)!\n", i); r = swtch(i); bwprintf(COM2, "And the kernel gave me %d!\n", r); for (r = 0; r < 500000; ++r); } bwputstr (COM2, "CPU Mode: "); print_mode(); bwputstr (COM2, "\n\n"); int x = 42; int b[5]; b[0] = 0xDEADBEEF; b[1] = 0xDEADBEEF; b[2] = 0xDEADBEEF; b[3] = 0xDEADBEEF; b[4] = 0xDEADBEEF; bwprintf (COM2, "x is %d\n", x); i = 5; while (i--) { bwprintf (COM2, "b[%d] = ", i); bwputr(COM2, b[i]); bwputstr (COM2, "\n");} b[2] -= x; b[3]--; bwputstr (COM2, "now b[2] = b[2] - x and b[3] = b[3] - 1...\n"); i = 5; while (i--) { bwprintf (COM2, "b[%d] = ", i); bwputr(COM2, b[i]); bwputstr (COM2, "\n");} }
void bootstrap (struct td *tds, void (*f)(), int *stacks) { bwprintf (COM2, "[s[2J[2;1000r[;H[45mThis is a taskbar." "[K[m[u"); bwprintf(COM2, "[?25l[2;1H"); bwputstr(COM2, "Welcome to\r\n" "+--------------------------------------------------+\r\n" "| ______ __ ______ ____ |\r\n" "| / __/ /________ __ _ / / ___ / / __ \\/ __/ |\r\n" "| _\\ \\/ __/ __/ _ \\/ ' \\/ _ \\/ _ \\/ / /_/ /\\ \\ |\r\n" "| /___/\\__/_/ \\___/_/_/_/_.__/\\___/_/\\____/___/ |\r\n" "| v0.0.3 (Techno Fitness) |\r\n" "+--------------------------------------------------+\r\n\r\n"); DPRINTFUNC ("bootstrap"); install_handler (); DPRINTOK ("Interrupt handler installed.\n"); enable_timer (); enable_interrupts (); _kCreate(tds, IDLE, f, 0, 0, stacks); DPRINTOK ("First user task created.\n"); DPRINTOK ("Booting complete.\n"); }
static void test_pqueue_many(void) { struct pqueue q; struct pqueue_node nodes[32]; struct pqueue_entry *min; int keys[32] = { 1, 20, 28, 0, 12, 12, 21, 29, 25, 22, 13, 18, 2, 31, 21, 8, 13, 10, 9, 2, 21, 20, 14, 14, 14, 21, 20, 31, 18, 13, 3, 24 }; bool incl[32]; int i, j, count, rc; for (i = 0; i < 32; i++) incl[i] = false; bwputstr(COM2, "test_pqueue_many..."); pqueue_init(&q, 32, nodes); count = 0; i = 0; while (count <= 16 - 2) { rc = pqueue_add(&q, i, keys[i]); assert(rc == 0); incl[i++] = true; rc = pqueue_add(&q, i, keys[i]); assert(rc == 0); incl[i++] = true; min = pqueue_peekmin(&q); assert(min != NULL); assert(incl[min->val]); assert(keys[min->val] == min->key); for (j = 0; j < 32; j++) assert(!incl[j] || keys[j] >= min->key); incl[min->val] = false; pqueue_popmin(&q); count++; } while (count > 0) { min = pqueue_peekmin(&q); assert(min != NULL); assert(incl[min->val]); assert(keys[min->val] == min->key); for (j = 0; j < 32; j++) assert(!incl[j] || keys[j] >= min->key); incl[min->val] = false; pqueue_popmin(&q); count--; if (count > 0 && count % 2 == 0) { for (i = 0; i < 32; i++) { if (incl[i]) break; } keys[i] = -i; rc = pqueue_decreasekey(&q, i, -i); assert(rc == 0); } } min = pqueue_peekmin(&q); assert(min == NULL); bwputstr(COM2, "ok\n"); }
void second () { bwputstr(COM2, "I AM IDLE\n"); while (1) {} }