Questions tagged [xv6]

xv6 is a small Unix-like teaching operating system made by MIT for its 6.828 OS course. It is inspired by Unix Version 6.

326 questions
3
votes
1 answer

Why return does not exit a process in xv6?

Here is my code for user/sleep.c: #include "kernel/types.h" #include "user/user.h" int main(int argc, char *argv[]) { if (argc < 2) { printf("You have forgotten to pass an argument."); exit(1); …
Maxime Vernier
  • 340
  • 1
  • 9
3
votes
1 answer

Location of the definition of open() in xv6

I have an assignment that has me design my own system call. To do this, I would like to view the definition of the open system call. By this, I mean I would like to see how the actual open(const char*, const int) is defined, not sys_open (Since I…
Flacarile
  • 69
  • 5
3
votes
2 answers

How does xv6 write to the terminal?

The printf function calls write (re. forktest.c): void printf ( int fd, char *s, ... ) { write( fd, s, strlen(s) ); } Passing 1 as the fd writes to the console (as 1 maps to stdout). But where is write defined? I only see its declaration in…
Jet Blue
  • 5,109
  • 7
  • 36
  • 48
3
votes
1 answer

Why does this program allocate 8 pages but can only fit in 2048 nodes whose size is 8 bytes?

A node is defined as follows: struct node { int value; struct node *next; }; By using sizeof(struct node) I learn that a node is 8 bytes(in xv6). So I use malloc to allocated some memory space to store some nodes. A single page…
K.Wu
  • 3,553
  • 6
  • 31
  • 55
3
votes
1 answer

Trying to understand UNIX system calls on XV6

I'm trying to write a simple system call on XV6 (documentation available here and Github here) in order to understand how they're implemented. I've used these steps In syscall.c, declared extern int sys_hello(void) and added [SYS_hello] sys_hello…
3
votes
1 answer

Stack frame manipulation in xv6 only works correctly with a printf()?

I'm trying to make an extension of the xv6 kernel for my Operating Systems class and I'm running into a strange bug that's taken up 5 hours of my time to no avail. I implemented a signal handling system that inserts a signal handling function and…
Mikey Chen
  • 2,370
  • 1
  • 19
  • 31
3
votes
1 answer

How to create files in the xv6?

I need save data generated during the run in files for later analysis. xv6 implement this primitive form and I have no idea how it works... Is there an easy way to do this?
Borinzinha
  • 41
  • 1
  • 3
3
votes
2 answers

Why xv6 scheduler calls sti() in the begining of every loop?

The companion book says The reason to enable interrupts periodically on an idling CPU is that there might be no RUNNABLE process because processes (e.g., the shell) are waiting for I/O; if the scheduler left interrupts disabled all the time,…
delphifirst
  • 1,781
  • 1
  • 14
  • 23
3
votes
1 answer

How to implement a priority scheduler in xv6 ?

Implement a priority scheduling algorithm in xv6? But i am unable to understand how to handle the scheduling in this. I am able to set the priorities using this code. int set_priority(int pid,int priority) { struct proc *p; …
MIXAM
  • 41
  • 1
  • 4
3
votes
1 answer

Ascii or scancodes or some sort of keyboard input wher Backspace = 0x100

Im working with XV6 MIT's Open Source OS . Trying to figure out on what earth can BACKSPACE = 0x100 ? I want to add functions like right arrow and left arrow to control the console and i cant find the right numbers to capture them. ex: #define…
dbkoren
  • 1,305
  • 1
  • 11
  • 16
2
votes
1 answer

xv6 rev6 strange code in syscall()

Any one can see why the following ifs, lines 3279-3285 in xv6-rev6 code, are used: int num; num = proc−>tf−>eax; if (num >= 0 && num < SYS_open && syscalls[num]) { proc−>tf−>eax = syscalls[num](); } else if (num >= SYS_open && num <…
Morass
  • 323
  • 1
  • 5
2
votes
2 answers

question about struct deep copy and shallow copy in c

im currently finishing 6.s081 by myself. and there are some codes i truely dont understand // Allocate process. if((np = allocproc()) == 0){ return -1; } // Copy user memory from parent to child. if(uvmcopy(p->pagetable,…
2
votes
1 answer

Trying to implement Priority Round Robin in xv6 but running into booting error

I'm trying to implement the priority round robin scheduling system in xv6 after fixing some lock errors which were causing a panic error but now I keep running into a booting error and my kernel gets stuck before booting up completely. xv6 kernel is…
Ayxux
  • 21
  • 3
2
votes
1 answer

Why there is no GDT in xv6-riscv?

In xv6-x86 every cpu struct has a gdt: struct cpu { uchar apicid; // LAPIC ID struct context *scheduler; struct taskstate ts; struct segdesc gdt[NSEGS]; // GDT volatile uint started; int ncli; int intena; struct proc…
ConnellyM
  • 173
  • 7
2
votes
1 answer

why timervec need to be set into mtvec in xv6?

In start.c/timerinit(), timervec be written into mtvec. But I don't know why this is needed? As before timerinit(), all interrupts & exceptions are already delegated to supervisor-mode via code: w_medeleg(0xffff); w_mideleg(0xffff); …
Shaq Xu
  • 21
  • 1
1 2
3
21 22