os161

thread_fork working on kernel

只谈情不闲聊 提交于 2021-02-17 06:09:02
问题 I am working on OS161 where C pthread library is not primarily supported. My current objective is to understand the sys calls and make some simple programs run. my simple function has following code: int id = 1; long id2 = 1; int ret = thread_fork("myThread", (void *)id, id2, void (*function)((void *)id, id2), NULL); kprintf("\nHello World\n"); return; ` where call to thread_fork is int thread_fork(const char *name, void *data1, unsigned long data2, void (*func)(void *, unsigned long), struct

thread_fork working on kernel

会有一股神秘感。 提交于 2021-02-17 06:07:56
问题 I am working on OS161 where C pthread library is not primarily supported. My current objective is to understand the sys calls and make some simple programs run. my simple function has following code: int id = 1; long id2 = 1; int ret = thread_fork("myThread", (void *)id, id2, void (*function)((void *)id, id2), NULL); kprintf("\nHello World\n"); return; ` where call to thread_fork is int thread_fork(const char *name, void *data1, unsigned long data2, void (*func)(void *, unsigned long), struct

thread_fork working on kernel

a 夏天 提交于 2021-02-17 06:05:13
问题 I am working on OS161 where C pthread library is not primarily supported. My current objective is to understand the sys calls and make some simple programs run. my simple function has following code: int id = 1; long id2 = 1; int ret = thread_fork("myThread", (void *)id, id2, void (*function)((void *)id, id2), NULL); kprintf("\nHello World\n"); return; ` where call to thread_fork is int thread_fork(const char *name, void *data1, unsigned long data2, void (*func)(void *, unsigned long), struct

Page number and offset

自闭症网瘾萝莉.ら 提交于 2021-02-05 13:05:29
问题 I am learning the different types of memory management. I don't understand the point of having an offset bits in a virtual address. And also why page sizes are made power of 2 ? My primary confusion is: give me an example of an offset being used in instruction to access a certain virtual address? My second confusion is: The usual statement is that if the size of logical address is 2^m and page size is 2^n , then the high-order m-n bits of a logical address designate the page number. 回答1: I

Makefile Errors - “***missing separator” & “***recipe commences before first target”

眉间皱痕 提交于 2019-12-25 05:19:14
问题 I am trying to build the userland for os161. When I type make in the command line I get the following error: Makefile 24: ***missing separator (did you mean TAB instead of 8 spaces?). Stop. I checked the Makefile at line 24 and tried adding a TAB to the start of the line, but that didn't work as I then get another error: Makefile 24: ***recipe commences before first target. Stop. Here is the full makefile for reference: # # Toplevel makefile for OS/161. # # # Main rules: # all (default):

Why one page table per process

不羁的心 提交于 2019-12-21 04:01:41
问题 At first I thought there is only one page table for the whole system. But there are actually one page table per process? What is the point of having multiple page table instead of one page table. I am implementing part of os161 回答1: A page table usually has a fixed number of entries and therefore describes only a portion of the entire virtual address space. This is why you need multiple of them to cover the entire address space. Now, in many OSes processes have individual (in other words, not

How does threads sleep with interrupt disabled?

风格不统一 提交于 2019-12-06 11:50:09
问题 I am trying to understand how the code below works. This is straight out of my profs lecture slides. This P() and V() function is the part of semaphore implementation in the OS that we use in class (OS161). I think you might need understanding of the OS161 to answer my question, since its widely used, hopefully some one can answer this questions. My understanding of this code with lecture notes: X:Flow of the P() function 1. When a thread call P(), we disable interrupt 2. check if we have any

How does threads sleep with interrupt disabled?

本小妞迷上赌 提交于 2019-12-04 17:18:54
I am trying to understand how the code below works. This is straight out of my profs lecture slides. This P() and V() function is the part of semaphore implementation in the OS that we use in class (OS161). I think you might need understanding of the OS161 to answer my question, since its widely used, hopefully some one can answer this questions. My understanding of this code with lecture notes: X:Flow of the P() function 1. When a thread call P(), we disable interrupt 2. check if we have any resources available on sem->count 3.a) if count is 0 then we go to sleep 3.b) if count != 0 then we

System calls overhead

倾然丶 夕夏残阳落幕 提交于 2019-11-27 02:52:57
问题 I just started studying about system calls. I would like to know what causes overhead when a system call is made. For example, if we consider getpid(), when a system call is made to getpid() my guess is that if the control is currently in the child process then a context switching has to be made to enter the parent process to get the pid. Can that contribute to overhead? Also when getpid() is called, there will be some metadata transfer across the user-space boundary and enters and exits the