xv6

Create new system-call in xv6 that returns data about an open files for all running processes

和自甴很熟 提交于 2020-06-29 04:32:16
问题 Im started to learn about xv6. And I'm trying to add a new system call that will print the list of open files for all running processes. It has to print pid of each process, its file descriptor number (0,1,2- for each pid), if the file is regular or piped and if the file is readable of writable. So I know is how to get the pid. Here is an example of a code: struct proc *p; sti(); acquire(&ptable.lock); cprintf("name \t pid \t type \t \n"); for (p=ptable.proc; p<&ptable.proc[NPROC]; p++){

How to pass a value into a system call function in XV6?

送分小仙女□ 提交于 2020-05-11 05:08:50
问题 I am attempting to create a simple priority based scheduler in XV6. To do this, I also have to create a system call that will allow a process to set its priority. I have done everything required to create the system call as discussed here and elsewhere: how do i add a system call / utility in xv6 The problem is, I cannot pass any variables when I call the function, or rather, it runs like nothing is wrong but the correct values do not show up inside the function. Extern declaration (syscall.c

How to pass a value into a system call function in XV6?

血红的双手。 提交于 2020-05-11 05:08:06
问题 I am attempting to create a simple priority based scheduler in XV6. To do this, I also have to create a system call that will allow a process to set its priority. I have done everything required to create the system call as discussed here and elsewhere: how do i add a system call / utility in xv6 The problem is, I cannot pass any variables when I call the function, or rather, it runs like nothing is wrong but the correct values do not show up inside the function. Extern declaration (syscall.c

How to modify process preemption policies (like RR time-slices) in XV6?

老子叫甜甜 提交于 2020-04-11 12:09:38
问题 Right now it seems that on every click tick, the running process is preempted and forced to yield the processor, I have thoroughly investigated the code-base and the only relevant part of the code to process preemption is below (in trap.c ): // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc() -> state == RUNNING && tf -> trapno == T_IRQ0 + IRQ_TIMER) yield(); I guess that timing is specified in T_IRQ0 +

How to modify process preemption policies (like RR time-slices) in XV6?

佐手、 提交于 2020-04-11 12:08:07
问题 Right now it seems that on every click tick, the running process is preempted and forced to yield the processor, I have thoroughly investigated the code-base and the only relevant part of the code to process preemption is below (in trap.c ): // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc() -> state == RUNNING && tf -> trapno == T_IRQ0 + IRQ_TIMER) yield(); I guess that timing is specified in T_IRQ0 +

How to pass a value into system call XV6

余生颓废 提交于 2020-01-06 05:21:53
问题 I am attempting to create a system call that will increment a number that was added to the cpu struct. However I believe that a sys call has to be void so how can I pass in a value when calling it for example. incrementNum(3); 回答1: Xv6 has its own functions for passing arguments from user space to kernel space (system call). You can use argint() to retrieve integer arguments in your system call and argstr() to retrieve string arguments. Passing arguments can be done the traditional way but

xv6 add a system call that counts system calls

大憨熊 提交于 2019-12-30 10:00:10
问题 EDIT: GOT IT here is what I did: in syscall.c: extern int numSysCalls; in sysproc.c: int numSysCalls = -1; Okay, so I'm working on implementing an easy system call that returns the number of times a system call has been made. Seems easy, but I'm getting an error I don't understand... Basically, here is what I did: in syscall.c there is a function called syscall() that checks whether it is a syscall or not. I have basically declared a variable and am incrementing it every time this function is

Add a generic file in xv6 makefile

拜拜、爱过 提交于 2019-12-24 10:39:54
问题 I'm currently studying the xv6 OS. I found out here how to add a system call by modifying the MAKEFILE file. My question is: how do we add simple text files or any other kind of file to be seen in the xv6 system once it boots? 回答1: README file in Xv6 is a generic file too. Searching for occurrences of README in the MakeFile and adding your required file will be sufficient. Suppose new.txt is the file you want to add. Parts of the MakeFile to be changed are: 1) fs.img: mkfs README new.txt $

small c compiler for educational purpose [closed]

↘锁芯ラ 提交于 2019-12-24 03:02:22
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Is there any small c compiler which follows ansi c extensions and still it has less than 10,000 LOC. Basically 'm trying to port such small compiler to one of such educational OS kernel known as xv6. Thanks. 回答1: I don't think that's possible. You might try something like https://github.com/alexfru/SmallerC , a

What does the declaration“extern struct cpu *cpu asm(“%gs:0”);” mean?

余生颓废 提交于 2019-12-18 04:59:15
问题 When I'm reading the xv6 source code, I'm confused about the syntax of the declaration below. Can anyone explain it to me? extern struct cpu *cpu asm("%gs:0"); 回答1: I assume you understand what extern struct cpu *cpu means. The question you have is: What does the asm("%gs:0") part mean? This code is using a gcc extension called asm labels to say that the variable cpu is defined by the assembler string %gs:0 . This is NOT how this extension is intended to be used and is considered a hack.