Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
abinade2
kernel
Commits
30f193b5
Commit
30f193b5
authored
7 years ago
by
kexu6
Browse files
Options
Downloads
Patches
Plain Diff
fix fd_check
parent
6c214cb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
student-distrib/proc.c
+10
-7
10 additions, 7 deletions
student-distrib/proc.c
student-distrib/terminal.c
+3
-4
3 additions, 4 deletions
student-distrib/terminal.c
student-distrib/types.h
+3
-4
3 additions, 4 deletions
student-distrib/types.h
with
16 additions
and
15 deletions
student-distrib/proc.c
+
10
−
7
View file @
30f193b5
...
@@ -27,10 +27,14 @@ void control_initilization(void)
...
@@ -27,10 +27,14 @@ void control_initilization(void)
//checking is fd is valid
//checking is fd is valid
int32_t
fd_check
(
int32_t
fd
)
int32_t
fd_check
(
int32_t
fd
)
{
{
if
(
control
.
terminal
[
control
.
cur_terminal
].
pcb
->
fd
[
fd
].
flags
!=
0
&&
if
(
fd
>=
MIN_FILE_NUM
&&
fd
>=
MIN_FILE_NUM
&&
fd
<
MAX_FILE_NUM
){
return
-
1
;
}
fd
<
MAX_FILE_NUM
){
return
1
;
}
else
{
return
0
;
}
// file not present
if
(
control
.
terminal
[
control
.
cur_terminal
].
pcb
->
fd
[
fd
].
flags
==
0
)
return
-
1
;
else
return
0
;
}
}
//clearing fd
//clearing fd
...
@@ -74,7 +78,6 @@ void pcb_init(pcb_t* pcb , uint8_t* parsed_cmd, uint8_t (*argv)[MAX_ARGUMENT_SIZ
...
@@ -74,7 +78,6 @@ void pcb_init(pcb_t* pcb , uint8_t* parsed_cmd, uint8_t (*argv)[MAX_ARGUMENT_SIZ
//initialize other things in pcb structures
//initialize other things in pcb structures
pcb
->
pid
=
pid
;
pcb
->
pid
=
pid
;
//pcb->parent_pid = (control.terminal[control.cur_terminal].terminal_prog_count - 1 == 0) ? pid - 1: control.terminal[control.cur_terminal].pcb->pid;
// no program other than the shell initiates another program
// no program other than the shell initiates another program
pcb
->
parent_pid
=
0
;
pcb
->
parent_pid
=
0
;
...
@@ -224,8 +227,8 @@ int32_t set_pid(void)
...
@@ -224,8 +227,8 @@ int32_t set_pid(void)
for
(
i
=
0
;
i
<
MAX_PROCESS
;
i
++
)
for
(
i
=
0
;
i
<
MAX_PROCESS
;
i
++
)
{
{
if
(
control
.
pid_array
[
i
]
==
0
){
if
(
control
.
pid_array
[
i
]
==
0
){
control
.
pid_array
[
i
]
=
1
;
control
.
pid_array
[
i
]
=
1
;
return
i
;
return
i
;
}
}
}
}
printf
(
"Reached maximum number of processes %d
\n
"
,
MAX_PROCESS
);
printf
(
"Reached maximum number of processes %d
\n
"
,
MAX_PROCESS
);
...
...
This diff is collapsed.
Click to expand it.
student-distrib/terminal.c
+
3
−
4
View file @
30f193b5
...
@@ -170,7 +170,7 @@ void init_terminal(void)
...
@@ -170,7 +170,7 @@ void init_terminal(void)
/*
/*
* FUNCTIONALITY: switching terminal
* FUNCTIONALITY: switching terminal
*
*
* INPUT: the terminal id of the
ther
terminal that we want to switch to
* INPUT: the terminal id of the terminal that we want to switch to
*
*
* OUTPUT: -2 - invalid terminal ID or maximum number of processes reached
* OUTPUT: -2 - invalid terminal ID or maximum number of processes reached
* -1 - trying to switch to same terminal
* -1 - trying to switch to same terminal
...
@@ -196,15 +196,14 @@ int32_t switch_terminal(int32_t term_id)
...
@@ -196,15 +196,14 @@ int32_t switch_terminal(int32_t term_id)
control
.
cur_terminal
=
term_id
;
control
.
cur_terminal
=
term_id
;
control
.
visible_terminal
=
term_id
;
control
.
visible_terminal
=
term_id
;
//store previous terminal data
//store previous terminal data into memory
//copy_term_data(prev_terminal, 0);
memcpy
(
(
void
*
)
control
.
terminal
[
prev_terminal
].
vid_mem
,
(
const
void
*
)
TERM_VID
,
_4_KB
);
memcpy
(
(
void
*
)
control
.
terminal
[
prev_terminal
].
vid_mem
,
(
const
void
*
)
TERM_VID
,
_4_KB
);
//remap_term(term_id);
//remap_term(term_id);
clear
();
clear
();
update_cursor
();
update_cursor
();
//
copy_term_data(control.cur_terminal, 1);
//
display new terminal video memory
memcpy
(
(
void
*
)
TERM_VID
,
(
const
void
*
)
control
.
terminal
[
term_id
].
vid_mem
,
_4_KB
);
memcpy
(
(
void
*
)
TERM_VID
,
(
const
void
*
)
control
.
terminal
[
term_id
].
vid_mem
,
_4_KB
);
//check if shell is running on that terminal
//check if shell is running on that terminal
...
...
This diff is collapsed.
Click to expand it.
student-distrib/types.h
+
3
−
4
View file @
30f193b5
...
@@ -161,9 +161,9 @@ typedef struct pcb {
...
@@ -161,9 +161,9 @@ typedef struct pcb {
/* Terminal structure - Up to 3 terminals supported */
/* Terminal structure - Up to 3 terminals supported */
typedef
struct
terminal
{
typedef
struct
terminal
{
pcb_t
*
pcb
;
pcb_t
*
pcb
;
int32_t
terminal_x
;
int32_t
terminal_x
;
// cursor location
int32_t
terminal_y
;
int32_t
terminal_y
;
// cursor location
int32_t
vid_mem
;
int32_t
vid_mem
;
int32_t
terminal_prog_count
;
int32_t
terminal_prog_count
;
...
@@ -193,7 +193,6 @@ typedef struct control {
...
@@ -193,7 +193,6 @@ typedef struct control {
/*---------------------------- Global variable -------------------------------*/
/*---------------------------- Global variable -------------------------------*/
/* Godlike--- */
control_t
control
;
control_t
control
;
f_table_t
dir_jumptable
;
f_table_t
dir_jumptable
;
...
...
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