Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
453c6a65
Commit
453c6a65
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
convert syscall dispatch to table
parent
c664dd5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
defs.h
+3
-0
3 additions, 0 deletions
defs.h
syscall.c
+28
-64
28 additions, 64 deletions
syscall.c
with
31 additions
and
64 deletions
defs.h
+
3
−
0
View file @
453c6a65
...
...
@@ -139,3 +139,6 @@ struct inode* mknod1(struct inode*, char*, short, short, short);
int
unlink
(
char
*
);
void
iupdate
(
struct
inode
*
);
int
link
(
char
*
,
char
*
);
// number of elements in fixed-size array
#define NELEM(x) (sizeof(x)/sizeof((x)[0]))
This diff is collapsed.
Click to expand it.
syscall.c
+
28
−
64
View file @
453c6a65
...
...
@@ -108,75 +108,39 @@ extern int sys_unlink(void);
extern
int
sys_wait
(
void
);
extern
int
sys_write
(
void
);
static
int
(
*
syscalls
[])(
void
)
=
{
[
SYS_chdir
]
sys_chdir
,
[
SYS_close
]
sys_close
,
[
SYS_dup
]
sys_dup
,
[
SYS_exec
]
sys_exec
,
[
SYS_exit
]
sys_exit
,
[
SYS_fork
]
sys_fork
,
[
SYS_fstat
]
sys_fstat
,
[
SYS_getpid
]
sys_getpid
,
[
SYS_kill
]
sys_kill
,
[
SYS_link
]
sys_link
,
[
SYS_mkdir
]
sys_mkdir
,
[
SYS_mknod
]
sys_mknod
,
[
SYS_open
]
sys_open
,
[
SYS_pipe
]
sys_pipe
,
[
SYS_read
]
sys_read
,
[
SYS_sbrk
]
sys_sbrk
,
[
SYS_unlink
]
sys_unlink
,
[
SYS_wait
]
sys_wait
,
[
SYS_write
]
sys_write
,
};
void
syscall
(
void
)
{
struct
proc
*
cp
=
curproc
[
cpu
()];
int
num
=
cp
->
tf
->
eax
;
int
ret
=
-
1
;
switch
(
num
){
case
SYS_fork
:
ret
=
sys_fork
();
break
;
case
SYS_exit
:
ret
=
sys_exit
();
break
;
case
SYS_wait
:
ret
=
sys_wait
();
break
;
case
SYS_pipe
:
ret
=
sys_pipe
();
break
;
case
SYS_write
:
ret
=
sys_write
();
break
;
case
SYS_read
:
ret
=
sys_read
();
break
;
case
SYS_close
:
ret
=
sys_close
();
break
;
case
SYS_kill
:
ret
=
sys_kill
();
break
;
case
SYS_exec
:
ret
=
sys_exec
();
break
;
case
SYS_open
:
ret
=
sys_open
();
break
;
case
SYS_mknod
:
ret
=
sys_mknod
();
break
;
case
SYS_unlink
:
ret
=
sys_unlink
();
break
;
case
SYS_fstat
:
ret
=
sys_fstat
();
break
;
case
SYS_link
:
ret
=
sys_link
();
break
;
case
SYS_mkdir
:
ret
=
sys_mkdir
();
break
;
case
SYS_chdir
:
ret
=
sys_chdir
();
break
;
case
SYS_dup
:
ret
=
sys_dup
();
break
;
case
SYS_getpid
:
ret
=
sys_getpid
();
break
;
case
SYS_sbrk
:
ret
=
sys_sbrk
();
break
;
default:
cprintf
(
"unknown sys call %d
\n
"
,
num
);
// Maybe kill the process?
break
;
if
(
num
>=
0
&&
num
<
NELEM
(
syscalls
)
&&
syscalls
[
num
])
cp
->
tf
->
eax
=
syscalls
[
num
]();
else
{
cprintf
(
"%d %s: unknown sys call %d
\n
"
,
cp
->
pid
,
cp
->
name
,
num
);
cp
->
tf
->
eax
=
-
1
;
}
cp
->
tf
->
eax
=
ret
;
}
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