Projects‎ > ‎

Project04

Virtual Memory, Kernel Threads, and the File System

Due Tuesday, December 6th at 11:59pm. Interactive Grading on Wednesday December 7th.

For this project you are going modify xv6 in three significant ways:
  1. Support for a shared memory region between two processes
  2. Support for kernel threads and synchronization
  3. Support for memory mapped files


Shared Memory Region

Your goal is to implement a new system call can setup a shared page of memory. Once the shared page has been configured, when you fork, both the parent and child will have access to the shared page. That is, if a parent writes into the shared page, the child will see the change and vice versa.
The system call looks like this:

void *sharedmem(void);

The return value will be a pointer to the new shared page.

You job is to implement the sharedmem() system call so that it allows a page to be shared between the parent and the forked child. You will need to write a user-level program that demonstrates your solution works.

Some things to consider:
  • Where to allocate the shared page?
  • How to keep track of the shared page?
  • What happens when processes with a shared page exit?
  • Can you share a page between more than two processes?


Kernel Threads and synchronization

For this problem you are going to add kernel-level thread support to xv6. You need to support the following API:

int thread_create(struct thread *t, int (*func)(void *), void *stack, void *arg);
int thread_exit(int exit_value);
int thread_join(struct thread *t);

int thread_lock_init(struct lock *l, int value);
int thread_lock_acquire(struct lock *l);
int thread_lock_release(struct lock *l);

Look at OSPP for guidance. You need to write test programs that demonstrate your new API works.

Memory Mapped Files

For this problem you are going to add the mmap() system call to xv6. This system call allows you to establish an memory mapped file in the user virtual address space so that instead of using read() and write() to access a file you can just access the file like a character array in memory.

Here is the system call:

void *mmap(void *addr, int length, int fd);

You can look a the Linux man page for help.

You need to develop a user-level program that show you can read and write to a memory mapped file. Do a read test first, then get writing working.





Comments