Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pa3
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Minju Choi
pa3
Commits
418af9fc
Commit
418af9fc
authored
4 years ago
by
Minju Choi
Browse files
Options
Downloads
Patches
Plain Diff
pa3
parent
eace80f0
Branches
master
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pa3.c
+6
-11
6 additions, 11 deletions
pa3.c
vm_14
+0
-0
0 additions, 0 deletions
vm_14
vm_14.c
+6
-6
6 additions, 6 deletions
vm_14.c
with
12 additions
and
17 deletions
pa3.c
+
6
−
11
View file @
418af9fc
...
...
@@ -79,11 +79,10 @@ void push_stack(int num)
int
cnt
=-
1
;
int
global_pd_index
=
0
;
int
mapcnt_index
=
0
;
struct
pte
*
pte
;
unsigned
int
alloc_page
(
unsigned
int
vpn
,
unsigned
int
rw
)
//vpn을 index로 사용?, 0 ~ 15
unsigned
int
alloc_page
(
unsigned
int
vpn
,
unsigned
int
rw
)
{
int
pd_index
=
vpn
/
NR_PTES_PER_PAGE
;
//outer의 인덱스
int
pte_index
=
vpn
%
NR_PTES_PER_PAGE
;
//ptes의 인덱스
...
...
@@ -132,9 +131,8 @@ unsigned int alloc_page(unsigned int vpn, unsigned int rw) //vpn을 index로 사
pte
->
pfn
=
ret
;
mapcounts
[
ret
]
++
;
mapcnt_index
++
;
if
(
ret
>=
0
)
//스택 비어있지 않아도 ret을 못 찾을 수 있음
..!!
if
(
ret
>=
0
)
//스택 비어있지 않아도 ret을 못 찾을 수 있음
return
ret
;
}
...
...
@@ -142,7 +140,6 @@ unsigned int alloc_page(unsigned int vpn, unsigned int rw) //vpn을 index로 사
cnt
++
;
pte
->
pfn
=
cnt
;
mapcounts
[
cnt
]
++
;
mapcnt_index
++
;
return
cnt
;
...
...
@@ -167,11 +164,9 @@ void free_page(unsigned int vpn) //맵카운트가 0일때는 free하고 0보다
pte
=
&
current
->
pagetable
.
outer_ptes
[
pd_index
]
->
ptes
[
pte_index
];
mapcounts
[
pte
->
pfn
]
--
;
mapcnt_index
--
;
push_stack
(
pte
->
pfn
);
int
tmp
=
pte
->
pfn
;
pte
->
pfn
=
0
;
pte
->
valid
=
false
;
pte
->
writable
=
false
;
...
...
@@ -289,7 +284,7 @@ here:
}
for
(
int
i
=
0
;
i
<=
global_pd_index
;
i
++
){
//current의 outertable이 몇개까지 있는지
!!!
for
(
int
i
=
0
;
i
<=
global_pd_index
;
i
++
){
//
global_pd_index :
current의 outertable이 몇개까지 있는지
if
(
!
child
.
pagetable
.
outer_ptes
[
i
])
child
.
pagetable
.
outer_ptes
[
i
]
=
malloc
(
sizeof
(
struct
pte_directory
));
...
...
@@ -305,12 +300,12 @@ here:
}
}
}
// printf("5. current=%d\n", current->pid);
list_add_tail
(
&
current
->
list
,
&
processes
);
child
.
pid
=
pid
;
///////////
child
.
pid
=
pid
;
ptbr
=
&
child
.
pagetable
;
current
=
&
child
;
// printf("6. current=%d\n", current->pid);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
vm_14
+
0
−
0
View file @
418af9fc
No preview for this file type
This diff is collapsed.
Click to expand it.
vm_14.c
+
6
−
6
View file @
418af9fc
...
...
@@ -109,7 +109,7 @@ void push_stack(int num)
int
cnt
=-
1
;
int
global_pd_index
=
0
;
int
mapcnt_index
=
0
;
//
int mapcnt_index=0;
struct
pte
*
pte
;
...
...
@@ -165,7 +165,7 @@ unsigned int alloc_page(unsigned int vpn, unsigned int rw) //vpn을 index로 사
pte
->
pfn
=
ret
;
mapcounts
[
ret
]
++
;
mapcnt_index
++
;
//
mapcnt_index++;
if
(
ret
>=
0
)
//스택 비어있지 않아도 ret을 못 찾을 수 있음..!!
return
ret
;
...
...
@@ -175,8 +175,8 @@ unsigned int alloc_page(unsigned int vpn, unsigned int rw) //vpn을 index로 사
cnt
++
;
pte
->
pfn
=
cnt
;
mapcounts
[
cnt
]
++
;
mapcnt_index
++
;
// printf("1 : %d\n", cnt);
//
mapcnt_index++;
return
cnt
;
}
...
...
@@ -190,11 +190,11 @@ void free_page(unsigned int vpn) //맵카운트가 0일때는 free하고 0보다
pte
=
&
current
->
pagetable
.
outer_ptes
[
pd_index
]
->
ptes
[
pte_index
];
mapcounts
[
pte
->
pfn
]
--
;
mapcnt_index
--
;
//
mapcnt_index--;
push_stack
(
pte
->
pfn
);
int
tmp
=
pte
->
pfn
;
//
int tmp = pte->pfn;
pte
->
pfn
=
0
;
pte
->
valid
=
false
;
pte
->
writable
=
false
;
...
...
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