Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/boot output #281

Open
wants to merge 3 commits into
base: riscv
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ volatile static int started = 0;
void
main()
{
// Initialize an array to hold a waitcycle count per cpu.
uint waitcycle[NCPU];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be an array?

Since, if I understand it correctly, main() is run by every cpu core independently, each with its own stack. If we put waitcycle on the stack, there is no need for this to be an array.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same asking


if(cpuid() == 0){
consoleinit();
printfinit();
printf("\n");
printf("xv6 kernel is booting\n");
printf("\n");
printf("\nxv6 kernel is booting\n\n");
kinit(); // physical page allocator
kvminit(); // create kernel page table
kvminithart(); // turn on paging
Expand All @@ -29,13 +30,17 @@ main()
fileinit(); // file table
virtio_disk_init(); // emulated hard disk
userinit(); // first user process
printf("\n");
printf("hart %d started\n", cpuid());
__sync_synchronize();
started = 1;
} else {
while(started == 0)
;
waitcycle[cpuid()]=0;
while(started == 0){
waitcycle[cpuid()]= waitcycle[cpuid()] + 1; //count the waitcylce per hart
}
__sync_synchronize();
printf("hart %d starting\n", cpuid());
printf("hart %d starting: wait cycle %d\n", cpuid(), waitcycle[cpuid()] );
kvminithart(); // turn on paging
trapinithart(); // install kernel trap vector
plicinithart(); // ask PLIC for device interrupts
Expand Down