Use this tag if your question is about the xv6 OS (a "pedagogical" reimplementation of Unix v6, as used in MIT's 6.828 course) and do NOT want to mislead people into giving answers which assume Linux or other modern Unix system, which are quite different both in their implementation and interfaces.
Questions tagged [xv6]
6 questions
2
votes
2 answers
open() console for default file descriptors
I'm reading a shell program implementation in C ( the xv6 shell from MIT's 6.828 Operating System Engineering course ).
The main() function for this shell starts with the following code:
//Assumes three file descriptors open
while((fd =…
Rany Albeg Wein
- 670
- 4
- 14
2
votes
3 answers
How does the shell/init create the stdio streams?
I am reading through the source of MIT's xv6 OS. This snippet comes at the beginning of sh.c:
// Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){
if(fd >= 3){
close(fd);
break;
}
}
I…
Shrikant Giridhar
- 1,267
- 2
- 11
- 13
1
vote
0 answers
Writing an OS shutdown process for QEMU (xv6)
Background: I'm using QEMU to virtualize xv6-riscv on top of WSL2. I'm looking to create some sort of clean OS shutdown process reminiscent of Linux's exit command. Currently I'm using Ctrl-a x to kill qemu, but I want to be able to do this…
Jakob Lovern
- 111
- 2
0
votes
1 answer
Working of grep in xv6 implementation?
char buf[1024];
void
grep(char *pattern, int fd)
{
int n, m;
char *p, *q;
m = 0;
while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){
m += n;
buf[m] = '\0';
p = buf;
while((q = strchr(p, '\n')) != 0){
*q = 0;
…
arka
- 193
- 5
0
votes
1 answer
Why can't user process READ memory in kernel address space?
It seems fairly obvious why user processes can't write or modify data on kernel address space. But I can't get my head around why they can't even read the data.
I know that a segmentation trap would occur in that case but what is the reason behind…
-1
votes
1 answer
What does file descriptor have to do with process table?
I have an interest in Operating Systems. So I am reading the xv6 book to understand Operating Systems. This is my first book on the subject. I read a line I couldn't understand.
Internally, the xv6 kernel uses the file descriptor as an index into a…
Vishal Dalwadi
- 101
- 3