Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
bf390361
Commit
bf390361
authored
18 years ago
by
rtm
Browse files
Options
Downloads
Patches
Plain Diff
system call arguments
parent
89eb5fbe
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
Makefile
+1
-0
1 addition, 0 deletions
Makefile
defs.h
+1
-0
1 addition, 0 deletions
defs.h
proc.c
+1
-2
1 addition, 2 deletions
proc.c
spinlock.c
+3
-3
3 additions, 3 deletions
spinlock.c
syscall.c
+40
-1
40 additions, 1 deletion
syscall.c
syscall.h
+1
-0
1 addition, 0 deletions
syscall.h
user1.c
+18
-1
18 additions, 1 deletion
user1.c
with
65 additions
and
7 deletions
Makefile
+
1
−
0
View file @
bf390361
...
...
@@ -34,6 +34,7 @@ vectors.S : vectors.pl
user1
:
user1.c
$(
CC
)
-nostdinc
-I
.
-c
user1.c
$(
LD
)
-N
-e
main
-Ttext
0
-o
user1 user1.o
$(
OBJDUMP
)
-S
user1
>
user1.asm
-include
*.d
...
...
This diff is collapsed.
Click to expand it.
defs.h
+
1
−
0
View file @
bf390361
...
...
@@ -6,6 +6,7 @@ void kinit(void);
// console.c
void
cprintf
(
char
*
fmt
,
...);
void
panic
(
char
*
s
);
void
cons_putc
(
int
);
// proc.c
struct
proc
;
...
...
This diff is collapsed.
Click to expand it.
proc.c
+
1
−
2
View file @
bf390361
...
...
@@ -95,7 +95,6 @@ swtch()
struct
proc
*
np
;
struct
proc
*
op
=
curproc
[
cpu
()];
cprintf
(
"swtch cpu %d op %x proc0 %x
\n
"
,
cpu
(),
op
,
proc
);
while
(
1
){
np
=
op
+
1
;
while
(
np
!=
op
){
...
...
@@ -107,7 +106,7 @@ swtch()
}
if
(
np
->
state
==
RUNNABLE
)
break
;
cprintf
(
"swtch: nothing to run
\n
"
);
//
cprintf("swtch: nothing to run\n");
release_spinlock
(
&
kernel_lock
);
acquire_spinlock
(
&
kernel_lock
);
}
...
...
This diff is collapsed.
Click to expand it.
spinlock.c
+
3
−
3
View file @
bf390361
...
...
@@ -15,14 +15,14 @@ acquire_spinlock(uint32_t* lock)
if
(
*
lock
==
cpu_id
)
return
;
while
(
cmpxchg
(
LOCK_FREE
,
cpu_id
,
lock
)
!=
cpu_id
)
{
;
}
cprintf
(
"acquired: %d
\n
"
,
cpu_id
);
//
cprintf ("acquired: %d\n", cpu_id);
}
void
release_spinlock
(
uint32_t
*
lock
)
{
int
cpu_id
=
cpu
();
cprintf
(
"release: %d
\n
"
,
cpu_id
);
//
cprintf ("release: %d\n", cpu_id);
if
(
*
lock
!=
cpu_id
)
panic
(
"release_spinlock: releasing a lock that i don't own
\n
"
);
*
lock
=
LOCK_FREE
;
...
...
@@ -32,7 +32,7 @@ void
release_grant_spinlock
(
uint32_t
*
lock
,
int
c
)
{
int
cpu_id
=
cpu
();
cprintf
(
"release_grant: %d -> %d
\n
"
,
cpu_id
,
c
);
//
cprintf ("release_grant: %d -> %d\n", cpu_id, c);
if
(
*
lock
!=
cpu_id
)
panic
(
"release_spinlock: releasing a lock that i don't own
\n
"
);
*
lock
=
c
;
...
...
This diff is collapsed.
Click to expand it.
syscall.c
+
40
−
1
View file @
bf390361
...
...
@@ -10,11 +10,38 @@
/*
* User code makes a system call with INT T_SYSCALL.
* System call number in %eax.
* Arguments on the stack.
* Arguments on the stack, from the user call to the C
* library system call function. The saved user %esp points
* to a saved frame pointer, a program counter, and then
* the first argument.
*
* Return value? Error indication? Errno?
*/
/*
* fetch 32 bits from a user-supplied pointer.
* returns 1 if addr was OK, 0 if illegal.
*/
int
fetchint
(
struct
proc
*
p
,
unsigned
addr
,
int
*
ip
)
{
*
ip
=
0
;
if
(
addr
>
p
->
sz
-
4
)
return
0
;
memcpy
(
ip
,
p
->
mem
+
addr
,
4
);
return
1
;
}
int
fetcharg
(
int
argno
,
int
*
ip
)
{
unsigned
esp
;
esp
=
(
unsigned
)
curproc
[
cpu
()]
->
tf
->
tf_esp
;
return
fetchint
(
curproc
[
cpu
()],
esp
+
8
+
4
*
argno
,
ip
);
}
void
sys_fork
()
{
...
...
@@ -72,6 +99,15 @@ sys_wait()
}
}
void
sys_cons_putc
()
{
int
c
;
fetcharg
(
0
,
&
c
);
cons_putc
(
c
&
0xff
);
}
void
syscall
()
{
...
...
@@ -89,6 +125,9 @@ syscall()
case
SYS_wait
:
sys_wait
();
break
;
case
SYS_cons_putc
:
sys_cons_putc
();
break
;
default:
cprintf
(
"unknown sys call %d
\n
"
,
num
);
// XXX fault
...
...
This diff is collapsed.
Click to expand it.
syscall.h
+
1
−
0
View file @
bf390361
#define SYS_fork 1
#define SYS_exit 2
#define SYS_wait 3
#define SYS_cons_putc 4
This diff is collapsed.
Click to expand it.
user1.c
+
18
−
1
View file @
bf390361
...
...
@@ -5,9 +5,26 @@ fork()
asm
(
"int $48"
);
}
void
cons_putc
(
int
c
)
{
asm
(
"mov $4, %eax"
);
asm
(
"int $48"
);
}
void
puts
(
char
*
s
)
{
int
i
;
for
(
i
=
0
;
s
[
i
];
i
++
)
cons_putc
(
s
[
i
]);
}
main
()
{
fork
();
// fork();
puts
(
"hello!
\n
"
);
while
(
1
)
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment