Changes in the README, changes to fork template.

This commit is contained in:
Bahadir Balban
2008-08-16 13:01:18 +03:00
parent d434ad4b40
commit f436b44e81
7 changed files with 138 additions and 42 deletions

View File

@@ -43,5 +43,7 @@ struct sys_shmget_args {
int sys_shmget(key_t key, int size, int shmflg);
int sys_fork(void);
#endif /* __MM0_SYSARGS_H__ */

View File

@@ -100,7 +100,7 @@ void handle_requests(void)
case L4_IPC_TAG_CLOSE:
sys_close(sender, (int)mr[0]);
break;
case L4_IPC_TAG_FSYNC:
sys_fsync(sender, (int)mr[0]);
break;
@@ -120,6 +120,10 @@ void handle_requests(void)
args->flags, args->fd, __pfn(args->offset));
break;
}
case L4_IPC_TAG_MMAP: {
sys_fork(sender);
break;
}
case L4_IPC_TAG_BRK: {
// sys_brk(sender, (void *)mr[0]);
// break;

View File

@@ -3,7 +3,7 @@
*
* Copyright (C) 2008 Bahadir Balban
*/
#include <syscalls.h>
int copy_tcb(struct tcb *p, struct tcb *c)
{
@@ -28,20 +28,33 @@ int do_fork(struct tcb *parent)
{
struct tcb *child;
/* Make all parent shadows read only */
vm_freeze_shadows(parent);
/* Create a new L4 thread with new space */
l4_thread_create(parent);
/* Create a new local tcb */
child = tcb_alloc_init();
/* Make all parent shadows read only */
vm_freeze_shadows(parent);
/* Copy parent tcb to child */
copy_tcb(struct tcb *parent, struct tcb *child);
/* FIXME: Copy parent page tables to child ??? */
/* FIXME: Copy parent register values to child ??? */
/*
* Allocate and copy parent pgd + all pmds to child.
*
* When a write fault occurs on any of the frozen shadows,
* fault handler creates a new shadow on top, if it hasn't,
* and then starts adding writeable pages to the new shadow.
* Every forked task will fault on every page of the frozen shadow,
* until all pages have been made copy-on-write'ed, in which case
* the underlying frozen shadow is collapsed.
*
* Every forked task must have its own copy of pgd + pmds because
* every one of them will have to fault on frozen shadows individually.
*/
/* FIXME: Need to copy parent register values to child ??? */
/* Notify fs0 about forked process */
vfs_send_fork(parent, child);