Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Project Purple Stallion
Pintos
Commits
4157d6d9
Commit
4157d6d9
authored
5 years ago
by
a2-stratford
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issues
parent
ce3d20cf
Branches
Branches containing commit
No related tags found
2 merge requests
!22
Merge Feature/system calls
,
!6
Implemented filesize system call
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
userprog/syscall.c
+13
-9
13 additions, 9 deletions
userprog/syscall.c
userprog/system_calls.h
+44
-17
44 additions, 17 deletions
userprog/system_calls.h
with
57 additions
and
26 deletions
userprog/syscall.c
+
13
−
9
View file @
4157d6d9
...
@@ -4,8 +4,6 @@
...
@@ -4,8 +4,6 @@
#include
"system_calls.h"
#include
"system_calls.h"
#include
"threads/interrupt.h"
#include
"threads/interrupt.h"
#include
"threads/thread.h"
#include
"threads/thread.h"
// Dependency for list_elem struct and list_next / is_tail functions
#include
"lib/kernel/list.h"
/* System call numbers. */
/* System call numbers. */
...
@@ -60,6 +58,9 @@ syscall_handler (struct intr_frame *f UNUSED)
...
@@ -60,6 +58,9 @@ syscall_handler (struct intr_frame *f UNUSED)
case
SYSCALL_HALT
:
case
SYSCALL_HALT
:
syscall_halt
(
f
);
syscall_halt
(
f
);
break
;
break
;
case
SYSCALL_EXIT
:
syscall_exit
(
f
);
break
;
case
SYSCALL_EXEC
:
case
SYSCALL_EXEC
:
syscall_exec
(
f
);
syscall_exec
(
f
);
break
;
break
;
...
@@ -69,11 +70,14 @@ syscall_handler (struct intr_frame *f UNUSED)
...
@@ -69,11 +70,14 @@ syscall_handler (struct intr_frame *f UNUSED)
case
SYSCALL_CREATE
:
case
SYSCALL_CREATE
:
syscall_create
(
f
);
syscall_create
(
f
);
break
;
break
;
case
SYSCALL_REMOVE
:
syscall_remove
(
f
);
break
;
case
SYSCALL_WRITE
:
case
SYSCALL_WRITE
:
syscall_write
(
f
);
syscall_write
(
f
);
break
;
break
;
case
SYSCALL_
FILESIZE
:
case
SYSCALL_
OPEN
:
syscall_
filesize
(
f
);
syscall_
open
(
f
);
break
;
break
;
default:
default:
printf
(
"WARNING: Invalid Syscall (%d)
\n
"
,
syscall_number
);
printf
(
"WARNING: Invalid Syscall (%d)
\n
"
,
syscall_number
);
...
...
This diff is collapsed.
Click to expand it.
userprog/system_calls.h
+
44
−
17
View file @
4157d6d9
#include
"filesys/file.h"
#include
"filesys/file.h"
#include
"threads/interrupt.h"
#include
"threads/interrupt.h"
#include
"lib/kernel/list.h"
// Added due to dependency for list_elem
#include
"filesys/file.c"
// Added due to dependency for file
// Maps file descriptions to the associated file structure
struct
file_map
{
struct
list_elem
list_element
;
// Defined in list.h
int
file_descriptor
;
struct
file
*
file
;
// Defined in file.c
};
/*
/*
* Terminates Pintos by calling shutdown_power_off()
* Terminates Pintos by calling shutdown_power_off()
...
@@ -18,6 +7,14 @@ struct file_map
...
@@ -18,6 +7,14 @@ struct file_map
*/
*/
void
syscall_halt
(
struct
intr_frame
*
f
);
void
syscall_halt
(
struct
intr_frame
*
f
);
/*
* Terminates the current user program, returning status to the kernel. If the
* process's parent waits for it (see below), this is the status that will be
* returned. Conventionally, a status of 0 indicates success and nonzero
* values indicate errors.
*/
void
syscall_exit
(
struct
intr_frame
*
f
);
/*
/*
* Runs the executable whose name is given in cmd_line, passing any given
* Runs the executable whose name is given in cmd_line, passing any given
* arguments, and returns the new process's program id (pid). Must return pid
* arguments, and returns the new process's program id (pid). Must return pid
...
@@ -34,11 +31,41 @@ void syscall_exec(struct intr_frame *f);
...
@@ -34,11 +31,41 @@ void syscall_exec(struct intr_frame *f);
void
syscall_wait
(
struct
intr_frame
*
f
);
void
syscall_wait
(
struct
intr_frame
*
f
);
/*
/*
* Returns the size, in bytes, of the file open as fd.
* Creates a new file called file initially initial_size bytes in size.
* Returns true if successful, false otherwise.
*/
void
syscall_create
(
struct
intr_frame
*
f
);
/*
* Writes size bytes from buffer to the open file fd.
* Returns the number of bytes actually written, which may be less than size if
* some bytes could not be written.
*/
*/
void
syscall_
filesiz
e
(
struct
intr_frame
*
f
)
void
syscall_
writ
e
(
struct
intr_frame
*
f
)
;
/*
/*
*
NOTE: There are more system calls implemented by Pintos but we are not
*
Opens the file called file. Returns a nonnegative integer handle called a
*
implementing them because the assignment brief does not ask of it
.
*
"file descriptor" (fd), or -1 if the file could not be opened
.
*/
*/
void
syscall_open
(
struct
intr_frame
*
f
);
/*
* Deletes the file called file. Returns true if successful, false otherwise.
* A file may be removed regardless of whether it is open or closed, and
* Removing an open file does not close it. See Removing an Open File, for
* Details.
*/
void
syscall_remove
(
struct
intr_frame
*
f
);
/*
* special additional stuff for handling file descriptors because they're annoying
*/
// returns NULL if the given file descriptor does not match a known file
struct
file
*
get_associated_file_pointer
(
int
fd
);
// remembers the given file, and returns int of file descriptor
// returns -1 if could not store it (means we've opened too many files)
int
associate_new_file_descriptor
(
struct
file
*
file_pointer
);
// disassociates the given file descriptor (and its associated pointer)
// returns false if this failed for some reason
bool
disassociate_file_descriptor
(
int
fd
);
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