Fixed 2 more fork issues

Added setting of spsr for the new task.
Added newly created task into mm0's global task list.
This commit is contained in:
Bahadir Balban
2008-08-27 22:27:53 +03:00
parent dad1d2d792
commit 4ffdb45550
7 changed files with 34 additions and 7 deletions
+2
View File
@@ -26,6 +26,8 @@
#define syscalls_end_offset sys_time_offset #define syscalls_end_offset sys_time_offset
#define SYSCALLS_TOTAL ((syscalls_end_offset >> 2) + 1) #define SYSCALLS_TOTAL ((syscalls_end_offset >> 2) + 1)
void print_syscall_context(struct ktcb *t);
int sys_ipc(struct syscall_context *); int sys_ipc(struct syscall_context *);
int sys_thread_switch(struct syscall_context *); int sys_thread_switch(struct syscall_context *);
int sys_thread_control(struct syscall_context *); int sys_thread_control(struct syscall_context *);
+10
View File
@@ -17,6 +17,16 @@
#include INC_API(syscall.h) #include INC_API(syscall.h)
#include INC_ARCH(exception.h) #include INC_ARCH(exception.h)
void print_syscall_context(struct ktcb *t)
{
syscall_context_t *r = t->syscall_regs;
printk("Thread id: %d registers: 0x%x, 0x%x, 0x%x, 0x%x, "
"0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
t->tid, r->spsr, r->r0, r->r1, r->r2, r->r3, r->r4,
r->r5, r->r6, r->r7, r->r8, r->sp_usr, r->lr_usr);
}
int sys_exchange_registers(syscall_context_t *regs) int sys_exchange_registers(syscall_context_t *regs)
{ {
struct ktcb *task; struct ktcb *task;
+9 -5
View File
@@ -6,6 +6,7 @@
#include <l4/generic/scheduler.h> #include <l4/generic/scheduler.h>
#include INC_API(syscall.h) #include INC_API(syscall.h)
#include <l4/api/thread.h> #include <l4/api/thread.h>
#include <l4/api/syscall.h>
#include <l4/api/errno.h> #include <l4/api/errno.h>
#include <l4/generic/tcb.h> #include <l4/generic/tcb.h>
#include <l4/lib/idpool.h> #include <l4/lib/idpool.h>
@@ -61,6 +62,7 @@ int thread_start(struct task_ids *ids)
return -EINVAL; return -EINVAL;
} }
extern unsigned int return_from_syscall; extern unsigned int return_from_syscall;
/* /*
@@ -107,12 +109,14 @@ int arch_setup_new_thread(struct ktcb *new, struct ktcb *orig)
new->syscall_regs->r0 = 0; new->syscall_regs->r0 = 0;
/* /*
* Set up the stack pointer and program counter so that next time * Set up the stack pointer, saved program status register and program
* the new thread schedules, it executes the end part of the system * counter so that next time the new thread schedules, it executes the
* call exception where the previous context is restored. * end part of the system call exception where the previous context is
* restored.
*/ */
new->context.sp = (unsigned long)new + syscall_context_offset; new->context.sp = (unsigned long)new->syscall_regs;
new->context.pc = (unsigned long)return_from_syscall; new->context.pc = (unsigned long)&return_from_syscall;
new->context.spsr = (unsigned long)orig->context.spsr;
/* Copy other relevant fields from original ktcb */ /* Copy other relevant fields from original ktcb */
new->pagerid = orig->pagerid; new->pagerid = orig->pagerid;
+1
View File
@@ -121,6 +121,7 @@ int pager_notify_fork(l4id_t sender, l4id_t parid,
memcpy(child->fd, parent->fd, TASK_FILES_MAX * sizeof(int)); memcpy(child->fd, parent->fd, TASK_FILES_MAX * sizeof(int));
l4_ipc_return(0); l4_ipc_return(0);
printf("%s/%s: Exiting...\n", __TASKNAME__, __FUNCTION__);
return 0; return 0;
} }
+1
View File
@@ -94,6 +94,7 @@ struct task_data_head {
}; };
struct tcb *find_task(int tid); struct tcb *find_task(int tid);
void task_add_global(struct tcb *t);
struct initdata; struct initdata;
void init_pm(struct initdata *initdata); void init_pm(struct initdata *initdata);
+4
View File
@@ -158,6 +158,10 @@ int do_fork(struct tcb *parent)
/* Notify fs0 about forked process */ /* Notify fs0 about forked process */
vfs_notify_fork(child, parent); vfs_notify_fork(child, parent);
/* Add child to global task list */
task_add_global(child);
printf("%s/%s: Starting forked child.\n", __TASKNAME__, __FUNCTION__);
/* Start forked child. */ /* Start forked child. */
l4_thread_control(THREAD_RUN, &ids); l4_thread_control(THREAD_RUN, &ids);
+7 -2
View File
@@ -43,6 +43,12 @@ void print_tasks(void)
} }
} }
void task_add_global(struct tcb *task)
{
list_add_tail(&task->list, &tcb_head.list);
tcb_head.total++;
}
struct tcb *find_task(int tid) struct tcb *find_task(int tid)
{ {
struct tcb *t; struct tcb *t;
@@ -276,8 +282,7 @@ int task_exec(struct vm_file *f, unsigned long task_region_start,
return err; return err;
/* Add the task to the global task list */ /* Add the task to the global task list */
list_add_tail(&task->list, &tcb_head.list); task_add_global(task);
tcb_head.total++;
/* Add the file to global vm lists */ /* Add the file to global vm lists */
list_del_init(&f->list); list_del_init(&f->list);