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

View File

@@ -26,6 +26,8 @@
#define syscalls_end_offset sys_time_offset
#define SYSCALLS_TOTAL ((syscalls_end_offset >> 2) + 1)
void print_syscall_context(struct ktcb *t);
int sys_ipc(struct syscall_context *);
int sys_thread_switch(struct syscall_context *);
int sys_thread_control(struct syscall_context *);

View File

@@ -17,6 +17,16 @@
#include INC_API(syscall.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)
{
struct ktcb *task;

View File

@@ -6,6 +6,7 @@
#include <l4/generic/scheduler.h>
#include INC_API(syscall.h)
#include <l4/api/thread.h>
#include <l4/api/syscall.h>
#include <l4/api/errno.h>
#include <l4/generic/tcb.h>
#include <l4/lib/idpool.h>
@@ -61,6 +62,7 @@ int thread_start(struct task_ids *ids)
return -EINVAL;
}
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;
/*
* Set up the stack pointer and program counter so that next time
* the new thread schedules, it executes the end part of the system
* call exception where the previous context is restored.
* Set up the stack pointer, saved program status register and program
* counter so that next time the new thread schedules, it executes the
* end part of the system call exception where the previous context is
* restored.
*/
new->context.sp = (unsigned long)new + syscall_context_offset;
new->context.pc = (unsigned long)return_from_syscall;
new->context.sp = (unsigned long)new->syscall_regs;
new->context.pc = (unsigned long)&return_from_syscall;
new->context.spsr = (unsigned long)orig->context.spsr;
/* Copy other relevant fields from original ktcb */
new->pagerid = orig->pagerid;

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));
l4_ipc_return(0);
printf("%s/%s: Exiting...\n", __TASKNAME__, __FUNCTION__);
return 0;
}

View File

@@ -94,6 +94,7 @@ struct task_data_head {
};
struct tcb *find_task(int tid);
void task_add_global(struct tcb *t);
struct initdata;
void init_pm(struct initdata *initdata);

View File

@@ -158,6 +158,10 @@ int do_fork(struct tcb *parent)
/* Notify fs0 about forked process */
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. */
l4_thread_control(THREAD_RUN, &ids);

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 *t;
@@ -276,8 +282,7 @@ int task_exec(struct vm_file *f, unsigned long task_region_start,
return err;
/* Add the task to the global task list */
list_add_tail(&task->list, &tcb_head.list);
tcb_head.total++;
task_add_global(task);
/* Add the file to global vm lists */
list_del_init(&f->list);