cp bin/hello /kernel/bin/
cp bin/shell /kernel/bin/
cp:
+ cd bin && make clean
cd bin && make
./scripts/copy.sh
int main()
{
printf("hello world\n");
- //syscall3(SYSC_WRITE, 0, "fuck", 5);
- //write(0, "hello world", sizeof("hello world"));
- //write(0, "hello world", 12);
-
+ while(1);
exit(0);
return 0;
#include <string.h>
int systest();
+int sysdebug();
int main()
{
- char x[10];
- x[0] = 'a';
- x[1] = 'b';
- x[2] = 'c';
- x[3] = '\n';
-#if 1
- //while(1) write(0, x, 4);
- //while(1) systest();
int pid = fork();
if(pid > 0)
{
- //write(0, "parent\n", 7);
- //write(0, x, 4);
+ printf("prarent child pid %u\n", pid);
while(1)
- ; systest();
+ {
+ systest();
+ sysdebug(0x112233);
+ }
}
else if(pid == 0)
-#endif
{
- //write(0, "child\n", 6);
- //write(0, x, 4);
+ printf("child\n");
+ execv("/bin/hello", 0);
while(1)
{
systest();
+ sysdebug(0xAABBCCDD);
}
}
+ else
+ {
+
+ }
return 0;
}
MPL_IDE,
MPL_IDE_INTR,
MPL_PREEMPT,
+ MPL_TEST,
+ MPL_DEBUG,
MPL_ROOT,
MPL_TASK_1,
MPL_TASK_2,
- MPL_TEST,
+ MPL_TASK_3,
+ MPL_TASK_4,
+ MPL_TASK_5,
+ MPL_TASK_6,
+ MPL_TASK_7,
+ MPL_TASK_8,
MPL_END
};
SYSC_STAT,
SYSC_EXIT,
SYSC_PAUSE,
- SYSC_TEST
+ SYSC_TEST,
+ SYSC_DEBUG
};
#endif // ASM
//pFile fps[NR_OPENS];
+ unsigned int cnt; // debug only
};
unsigned char stack[TASK_SIZE];
#define ROOT_TSK_PID (0)
-#define TASK_INIT_WEIGHT 10
+#define TASK_INIT_WEIGHT 0
#define get_tsk_from_list(p) list_entry((p), Task, list)
#define del_tsk_from_list(tsk) list_del((&tsk->list))
load_cr3(current);
- disable_irq();
pt_regs_t *regs = ((pt_regs_t *)(TASK_SIZE+(unsigned long)current)) - 1;
memset((void*)regs, 0, sizeof(pt_regs_t));
while(1)
{
- printl(MPL_TASK_1+id-1, "task:%d [%08x] weight %d cnt %d", id, current, current->weight, cnt++);
- int v = debug_wait_queue_get();
- printk("task:%d wait queue get %d\n", id, v);
+ sysc_test();
+ //printl(MPL_TASK_1+id-1, "task:%d [%08x] weight %d cnt %d", id, current, current->weight, cnt++);
+ int v = 0; //debug_wait_queue_get();
+ //printk("task:%d wait queue get %d\n", id, v);
}
}
int cnt = 0;
while(1)
{
- printl(MPL_ROOT, "root:0 [%08x] weight %d cnt %d", current, root_task.weight, cnt++);
+ sysc_test();
+ //printl(MPL_ROOT, "root:0 [%08x] weight %d cnt %d", current, root_task.weight, cnt++);
asm("sti;hlt;");
//sysc_test();
//syscall0(SYSC_TEST);
unsigned long schedule()
{
+ static turn = 0;
task_union *sel = &root_task;
task_union *p = 0;
list_head_t *pos = 0, *t=0;
- unsigned int max_weight = 0;
-
unsigned long iflags;
irq_save(iflags);
list_for_each_safe(pos, t, &root_task.list)
if(p->state != TASK_RUNNING)
{
- if(p->state == TASK_EXEC)
- p->state = TASK_RUNNING;
continue;
}
- if(p->weight > max_weight)
- {
- max_weight = p->weight;
- sel = p;
- }
+ printd("%08x weight %d\n", p, p->weight);
- else if(p->weight == 0)
+ if(p->weight != turn)
{
- p->weight = TASK_INIT_WEIGHT;
+ p->weight = turn;
+ sel = p;
+ break;
}
}
irq_restore(iflags);
- sel->weight--;
+ if(sel == &root_task)
+ {
+ turn ++;
+ }
+
+ printl(MPL_ROOT+sel->pid, "task:%d [%08x] turn %d cnt %u", sel->pid, sel, sel->weight, sel->cnt);
task_union *prev = current;
task_union *next = sel;
if(prev != next)
{
- printd("select %08x\n", next);
+ printd("[s:%08x]\n", next);
context_switch(prev, next);
}
}
int sysc_test()
{
static unsigned int cnt=0;
- printl(MPL_TEST, "sysc_test %u", cnt++);
+ current->cnt++;
+ printl(MPL_TEST, "sysc_test cnt %u current %08x cnt %u",
+ cnt++, current, current->cnt);
+}
- //unsigned long *pde = (unsigned long *)current->cr3;
- //printk("sysctest %08x\n", pde[797]);
+int sysc_debug(unsigned int v)
+{
+ static unsigned int cnt=0;
+ printl(MPL_DEBUG, "Task Debug Syscall %u Value %08x", cnt++, v);
}
void init_sysc_handler_table()
_sysc_(SYSC_EXIT, sysc_exit);
_sysc_(SYSC_PAUSE, sysc_pause);
_sysc_(SYSC_TEST, sysc_test);
+ _sysc_(SYSC_DEBUG, sysc_debug);
}
int sysc_bad_syscnr()
{
return syscall0(SYSC_TEST);
}
+
+int sysdebug(unsigned int v)
+{
+ //return syscall1(SYSC_DEBUG, v);
+ return syscall1(SYSC_DEBUG, 1);
+}
// "movl $1f, %%edi;"
//
#define SYSENTER_ASM \
- "pushl $1f;" \
+ "pushl $1f;" \
"pushl %%ecx;" \
"pushl %%edx;" \
"pushl %%ebp;" \