Permalink
Browse files

Part 6, getpid

  • Loading branch information...
singpolyma committed Aug 16, 2012
1 parent b391a07 commit 43a43fa0b212193132427eff03d518aa6c124707
Showing with 11 additions and 2 deletions.
  1. +1 −0 asm.h
  2. +4 −2 kernel.c
  3. +6 −0 syscalls.s
View
1 asm.h
@@ -1,2 +1,3 @@
unsigned int *activate(unsigned int *stack);
int fork(void);
int getpid(void);
View
@@ -62,7 +62,7 @@ int main(void) {
tasks[current_task] = activate(tasks[current_task]);
switch(tasks[current_task][2+7]) {
case 0x1:
case 0x1: /* fork */
if(task_count == TASK_LIMIT) {
/* Cannot create a new task, return error */
tasks[current_task][2+0] = -1;
@@ -82,10 +82,12 @@ int main(void) {
task_count++;
}
break;
case 0x2: /* getpid */
tasks[current_task][2+0] = current_task;
break;
case -4: /* Timer 0 or 1 went off */
if(*(TIMER0 + TIMER_MIS)) { /* Timer0 went off */
*(TIMER0 + TIMER_INTCLR) = 1; /* Clear interrupt */
bwputs("tick\n");
}
}
View
@@ -4,3 +4,9 @@ fork:
mov r7, #0x1
svc 0
bx lr
.global getpid
getpid:
push {r7}
mov r7, #0x2
svc 0
bx lr

0 comments on commit 43a43fa

Please sign in to comment.