Skip to content

Commit bc5bb4a

Browse files
per-cpu task lists and init task list on APs
1 parent ced73a7 commit bc5bb4a

File tree

5 files changed

+141
-77
lines changed

5 files changed

+141
-77
lines changed

include/taskswitch.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ process_t* proc_find(pid_t pid);
9292
*
9393
* @return process_t* process detail or NULL if no current process
9494
*/
95-
process_t* proc_cur();
95+
process_t* proc_cur(uint8_t logical_cpu);
9696

9797
/**
9898
* @brief Mark a process as waiting for another process to complete
@@ -133,13 +133,9 @@ void proc_kill(process_t* proc);
133133
*/
134134
bool proc_kill_id(pid_t id);
135135

136-
/**
137-
* @brief Display a diagnostic list of all processes
138-
*/
139-
void proc_show_list();
140-
141136
/**
142137
* @brief Run the process scheduling loop.
138+
* Each AP and the BSP all have a proc_loop().
143139
* @note Does not return
144140
*/
145141
_Noreturn void proc_loop();

src/ap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ void kmain_ap(struct limine_smp_info *info)
3939
* see if a process ours is waiting on still lives.
4040
*/
4141
dprintf("Got start signal on cpu #%d\n", info->processor_id);
42-
wait_forever();
42+
43+
proc_loop();
4344
}

src/basic/file_io.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
const char* make_full_path(const char* relative)
88
{
9+
uint8_t cpu = logical_cpu_id();
910
if (*relative == '/') {
1011
dprintf("make_full_path %s -> %s\n", relative, relative);
1112
return relative;
1213
}
1314

14-
const char* csd = proc_cur()->csd;
15+
const char* csd = proc_cur(cpu)->csd;
1516
char qualified_path[MAX_STRINGLEN];
1617

1718
if (*relative == 0) {
@@ -309,16 +310,18 @@ char* basic_ramdisk_from_size(struct basic_ctx* ctx)
309310

310311
char* basic_csd(struct basic_ctx* ctx)
311312
{
312-
return gc_strdup(proc_cur()->csd);
313+
return gc_strdup(proc_cur(logical_cpu_id())->csd);
313314
}
314315

315316
void chdir_statement(struct basic_ctx* ctx)
316317
{
317318
accept_or_return(CHDIR, ctx);
318319
const char* csd = str_expr(ctx);
319320
accept_or_return(NEWLINE, ctx);
320-
const char* old = strdup(proc_cur()->csd);
321-
const char* new = proc_set_csd(proc_cur(), csd);
321+
uint8_t cpu = logical_cpu_id();
322+
process_t* proc = proc_cur(cpu);
323+
const char* old = strdup(proc->csd);
324+
const char* new = proc_set_csd(proc, csd);
322325
if (new && fs_is_directory(new)) {
323326
kfree_null(&old);
324327
return;
@@ -329,7 +332,7 @@ void chdir_statement(struct basic_ctx* ctx)
329332
tokenizer_error_print(ctx, "Not a directory");
330333
}
331334

332-
proc_set_csd(proc_cur(), old);
335+
proc_set_csd(proc, old);
333336
kfree_null(&old);
334337
}
335338

src/basic/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,11 @@ void init_local_heap(struct basic_ctx* ctx)
605605

606606
void chain_statement(struct basic_ctx* ctx)
607607
{
608+
uint32_t cpu = logical_cpu_id();
609+
process_t* proc = proc_cur(cpu);
608610
accept_or_return(CHAIN, ctx);
609611
const char* pn = str_expr(ctx);
610-
process_t* p = proc_load(pn, ctx->cons, proc_cur()->pid, proc_cur()->csd);
612+
process_t* p = proc_load(pn, ctx->cons, proc->pid, proc->csd);
611613
if (p == NULL) {
612614
accept_or_return(NEWLINE, ctx);
613615
return;
@@ -634,7 +636,7 @@ void chain_statement(struct basic_ctx* ctx)
634636
}
635637
}
636638

637-
proc_wait(proc_cur(), p->pid);
639+
proc_wait(proc, p->pid);
638640
accept_or_return(NEWLINE, ctx);
639641
}
640642

0 commit comments

Comments
 (0)