Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos_Student
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
f2-zakir
Pintos_Student
Commits
8f637be1
There was an error fetching the commit references. Please try again later.
Commit
8f637be1
authored
1 year ago
by
f2-zakir
Browse files
Options
Downloads
Patches
Plain Diff
Update syscall.c
parent
77921155
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/userprog/syscall.c
+3
-30
3 additions, 30 deletions
src/userprog/syscall.c
with
3 additions
and
30 deletions
src/userprog/syscall.c
+
3
−
30
View file @
8f637be1
...
...
@@ -13,54 +13,27 @@ static void syscall_handler(struct intr_frame *);
bool
create
(
const
char
*
file
,
unsigned
initial_size
);
tid_t
exec
(
const
char
*
cmd_line
);
void
syscall_init
(
void
)
{
intr_register_int
(
0x30
,
3
,
INTR_ON
,
syscall_handler
,
"syscall"
);
}
static
void
syscall_handler
(
struct
intr_frame
*
f
)
{
// Get the syscall number from the stack
int
syscall_num
=
*
(
int
*
)
f
->
esp
;
switch
(
syscall_num
)
{
case
SYS_REMOVE
:
// Print current syscall number
printf
(
"Syscall_handler() - %d!
\n
"
,
syscall_num
);
filesys_remove
(
*
(
char
**
)(
f
->
esp
+
4
));
printf
(
*
(
char
**
)(
f
->
esp
+
4
));
break
;
case
SYS_EXEC
:
// Print current syscall number
printf
(
"Syscall_handler() - %d!
\n
"
,
syscall_num
);
printf
(
"SYS_CALL : EXEC
\n
"
);
exec
(
*
(
char
**
)(
f
->
esp
+
4
));
process_execute
(
*
(
char
**
)(
f
->
esp
+
4
));
break
;
case
SYS_CREATE
:
// Print current syscall number
printf
(
"Syscall_handler() - %d!
\n
"
,
syscall_num
);
create
(
*
(
int
*
)(
f
->
esp
+
4
),
(
unsigned
)
*
(
int
*
)(
f
->
esp
+
8
));
filesys_create
(
*
(
char
**
)(
f
->
esp
+
4
),
(
unsigned
)
*
(
int
*
)(
f
->
esp
+
8
));
break
;
default:
thread_exit
();
}
}
tid_t
exec
(
const
char
*
cmd_line
)
{
// showing the arg/process in the command line
printf
(
"
\n
cmd_line : '%s'
\n
"
,
cmd_line
);
// executing whatever in cmd_line then return to the process id
tid_t
pid
=
process_execute
(
cmd_line
);
return
pid
;
}
bool
create
(
const
char
*
file
,
unsigned
initial_size
)
{
// This creates a new file but doesn't open it
printf
(
"File named '%s' created
\n
"
,
file
);
return
filesys_create
(
file
,
initial_size
);
}
\ No newline at end of file
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