xv6-riscv | dennis ritchie 's and ken thompson
kandi X-RAY | xv6-riscv Summary
kandi X-RAY | xv6-riscv Summary
xv6 is a re-implementation of dennis ritchie's and ken thompson's unix version 6 (v6). xv6 loosely follows the structure and style of v6, but is implemented for a modern risc-v multiprocessor using ansi c. xv6 is inspired by john lions's commentary on unix 6th edition (peer to peer communications; isbn: 1-57398-013-7; 1st edition (june 14, 2000)). see also which provides pointers to on-line resources for v6. the following people have made contributions: russ cox (context switching, locking), cliff frey (mp), xiao yu (mp), nickolai zeldovich, and austin clements. we are also grateful for the bug reports and patches contributed by silas boyd-wickizer, anton burtsev, dan cross, cody cutler, mike cat, tej chajed, asami doi, eyalz800, , nelson elhage, saar ettinger, alice ferrazzi, nathaniel filardo, peter froehlich, yakir goaron,shivam handa, bryan henry, jaichenhengjie, jim huang, alexander kapshuk, anders kaseorg, kehao95, wolfgang keller, jonathan kimmitt, eddie kohler,
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of xv6-riscv
xv6-riscv Key Features
xv6-riscv Examples and Code Snippets
Community Discussions
Trending Discussions on xv6-riscv
QUESTION
In the user/usys.S
here a fragment which is generate by the usys.pl script
ANSWER
Answered 2021-Dec-22 at 19:20Let's just talk about sleep
. In one of your earlier questions, you posted a link to the user.h header file.
That header file tells your C compiler what arguments the function takes and what the function returns, on this line:
QUESTION
In the user.h
https://github.com/mit-pdos/xv6-riscv/blob/a1da53a5a12e21b44a2c79d962a437fa2107627c/user/user.h#L6
exit is only syscall defined this way
int exit(int) __attribute__((noreturn));
why this is needed for the exit function declaration?
ANSWER
Answered 2021-Dec-21 at 18:50I don't think the noreturn
attribute is strictly required, but it helps.
The noreturn
attribute tells the compiler that the exit
function will never return. In theory, this allows the compiler to better understand the possible code paths of any code that calls exit
, so it can display more accurate warnings and optimize the code better.
QUESTION
What is the use of the stat.h
header in cat.c
?
Here you have the cat.c
https://github.com/mit-pdos/xv6-riscv/blob/riscv/user/cat.c
Here you have the stat.h
https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/stat.h
I do not see any direct use of the stat
struct in the cat.c
so I wonder if there is an indirect one.
ANSWER
Answered 2021-Dec-19 at 13:38It was added in this commit probably because user.h uses the struct stat *
datatype
QUESTION
Despite consulting the documentation, I still can't understand this line:swtch(&c->scheduler, &p->context);
.
My question: I know this line is to switch p->context, including save registers and restore registers, but I can't understand the pc
change in this process, that is what execution order of this code? After theswtch(&c->scheduler, &p->context);
is executed, is it immedidate to execute c->proc = 0;
, then the effect of executing c->proc=p;
disappears? I am confused now.
code link: https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/proc.c line 456
...ANSWER
Answered 2021-Jun-04 at 13:21This is literally the code that was so confusing that its original authors wrote "You are not expected to understand this" in the comments, so don't feel bad for not understanding it.
The key thing you may have missed is that p->context
contains an address where swtch
is to resume execution of process p
. It's set up, for instance, here:
QUESTION
On Ubuntu 20.04, I installed the xv6 project using the page Tools Used in 6.828
...ANSWER
Answered 2021-Mar-20 at 06:47This has been mentioned in Tools Used in 6.S081
At this moment in time, it seems that the package qemu-system-misc has received an update that breaks its compatibility with our kernel. If you run make qemu and the script appears to hang after
QUESTION
I want to implement sleep
utility that receives number of seconds as an input and pauses for given seconds on a educatational xv6
operation system that runs on risc-v
processors.
The OS already have system call that get number of ticks and pauses: https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/sysproc.c#L56
Timers are initialized using a timer vector: https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/kernelvec.S#L93
The timer vector is initialized with CLINT_MTIMECMP
function that tells timer controller when to wake the next interrupt.
What I do not understand is how to know the time between the ticks and how many ticks are done during 1 second.
...ANSWER
Answered 2020-Aug-04 at 08:17Edit: A quick google of "qemu timebase riscv mtime" found a google groups chat which states that RDTIME is nanoseconds since boot and mtime is an emulated 10Mhz clock.
I haven't done a search to find the information you need, but I think I have some contextual information that would help you find it. I would recommend searching QEMU documentation / code (probably from Github search)for how mtime
and mtimecmp
work.
In section 10.1 (Counter - Base Counter and Timers) of specification1, it is explained that the RDTIME psuedo-instruction should have some fixed tick rate that can be determined based on the implementation 2. That tick rate would also be shared for mtimecmp
and mtime
as defined in the privileged specification 3.
I would presume the ticks used be the sleep system call would be the same as these ticks from the specifications. In that case, xv6 is just a kernel and wouldn't then define how many ticks/second there are. It seems that xv6 is made to run on top of qemu so the definition of ticks/second should be defined somewhere in the qemu code and might be documented.
From the old wiki for QEMU-riscv it should be clear that the SiFive CLINT defines the features xv6 needs to work, but I doubt that it specifies how to know the tickrate. Spike also supports the CLINT interface so it may also be instructive to search for the code in spike that handles it.
1 I used version 20191213 of the unprivileged specification as a reference
2
The RDTIME pseudoinstruction reads the low XLEN bits of the time CSR, which counts wall-clock real time that has passed from an arbitrary start time in the past. RDTIMEH is an RV32I-only in- struction that reads bits 63–32 of the same real-time counter. The underlying 64-bit counter should never overflow in practice. The execution environment should provide a means of determining the period of the real-time counter (seconds/tick). The period must be constant. The real-time clocks of all harts in a single user application should be synchronized to within one tick of the real-time clock. The environment should provide a means to determine the accuracy of the clock.
3
3.1.10 Machine Timer Registers (mtime and mtimecmp) Platforms provide a real-time counter, exposed as a memory-mapped machine-mode read-write register, mtime. mtime must run at constant frequency, and the platform must provide a mechanism for determining the timebase of mtime.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install xv6-riscv
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page