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
s2-fidan
Pintos_Student
Commits
0ee4d185
Commit
0ee4d185
authored
2 years ago
by
s2-fidan
Browse files
Options
Downloads
Patches
Plain Diff
changes
parent
c340daea
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/userprog/syscall.c
+32
-9
32 additions, 9 deletions
src/userprog/syscall.c
src/userprog/syscall.h
+2
-1
2 additions, 1 deletion
src/userprog/syscall.h
with
34 additions
and
10 deletions
src/userprog/syscall.c
+
32
−
9
View file @
0ee4d185
...
@@ -40,21 +40,23 @@ syscall_handler (struct intr_frame *f UNUSED)
...
@@ -40,21 +40,23 @@ syscall_handler (struct intr_frame *f UNUSED)
get_argument
(
esp
,
argument
,
1
);
get_argument
(
esp
,
argument
,
1
);
syscall_exit
(
argument
[
0
]);
syscall_exit
(
argument
[
0
]);
break
;
break
;
case
SYS_WAIT
:
// 2
case
SYS_EXEC
:
// 2 (TODO: Change to execute)
printf
(
"System Executing..."
);
get_argument
(
esp
,
argument
,
1
);
get_argument
(
esp
,
argument
,
1
);
f
->
eax
=
syscall_wait
(
argument
[
0
]);
check_address
((
void
*
)
argument
[
0
]);
f
->
eax
=
syscall_exec
((
const
char
*
)
argument
[
0
]);
break
;
break
;
case
SYS_CREATE
:
//
3
case
SYS_CREATE
:
//
4
get_argument
(
esp
,
argument
,
2
);
get_argument
(
esp
,
argument
,
2
);
check_address
((
void
*
)
argument
[
0
]);
check_address
((
void
*
)
argument
[
0
]);
f
->
eax
=
syscall_create
((
const
char
*
)
argument
[
0
],(
unsigned
)
argument
[
1
]);
f
->
eax
=
syscall_create
((
const
char
*
)
argument
[
0
],(
unsigned
)
argument
[
1
]);
break
;
break
;
case
SYS_REMOVE
:
//
4
case
SYS_REMOVE
:
//
5
get_argument
(
esp
,
argument
,
1
);
get_argument
(
esp
,
argument
,
1
);
check_address
((
void
*
)
argument
[
0
]);
check_address
((
void
*
)
argument
[
0
]);
f
->
eax
=
syscall_remove
((
const
char
*
)
argument
[
0
]);
f
->
eax
=
syscall_remove
((
const
char
*
)
argument
[
0
]);
break
;
break
;
case
SYS_WRITE
:
//
5
case
SYS_WRITE
:
//
9
get_argument
(
esp
,
argument
,
3
);
get_argument
(
esp
,
argument
,
3
);
check_address
((
void
*
)
argument
[
1
]);
check_address
((
void
*
)
argument
[
1
]);
f
->
eax
=
syscall_write
(
argument
[
0
],(
void
*
)
argument
[
1
],(
unsigned
)
argument
[
2
]);
f
->
eax
=
syscall_write
(
argument
[
0
],(
void
*
)
argument
[
1
],(
unsigned
)
argument
[
2
]);
...
@@ -86,10 +88,31 @@ void syscall_exit(int status) {
...
@@ -86,10 +88,31 @@ void syscall_exit(int status) {
thread_exit
();
thread_exit
();
}
}
/* Wait */
/* Execute */
int
syscall_wait
(
tid_t
tid
)
/* create child process and wait until childprocess is loaded */
/* runs the executable whose name is given */
tid_t
syscall_exec
(
const
char
*
argument
)
{
printf
(
"Exec : %s
\n
"
,
argument
);
/*dynamically create struct child*/
struct
thread
*
child_process
;
/*new process'c program id*/
tid_t
pid
;
pid
=
process_execute
(
argument
);
/* the child calls sema_up after the done in load()*/
child_process
=
get_child_process
(
pid
);
/*Call sema_down before we return, so parent process cannot return from the exec call
until it knows that the child process has loaded or not.
Only the parent process proceed past the sema_down line and return.*/
sema_down
(
&
(
child_process
->
load_semaphore
));
if
(
child_process
->
load_success
==
true
)
return
pid
;
else
{
{
return
process_wait
(
tid
);
return
-
1
;
}
}
}
/* Create File */
/* Create File */
...
...
This diff is collapsed.
Click to expand it.
src/userprog/syscall.h
+
2
−
1
View file @
0ee4d185
...
@@ -11,7 +11,8 @@ void get_argument(void *esp, int *argument, int count);
...
@@ -11,7 +11,8 @@ void get_argument(void *esp, int *argument, int count);
void
syscall_halt
(
void
);
void
syscall_halt
(
void
);
void
syscall_exit
(
int
status
);
void
syscall_exit
(
int
status
);
int
syscall_wait
(
tid_t
tid
);
tid_t
syscall_exec
(
const
char
*
command
);
bool
syscall_create
(
const
char
*
file_name
,
unsigned
initial_size
);
bool
syscall_create
(
const
char
*
file_name
,
unsigned
initial_size
);
bool
syscall_remove
(
const
char
*
file_name
);
bool
syscall_remove
(
const
char
*
file_name
);
int
syscall_write
(
int
fd
,
void
*
buffer
,
unsigned
size
);
int
syscall_write
(
int
fd
,
void
*
buffer
,
unsigned
size
);
...
...
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