Skip to content
GitLab
Explore
Sign in
Register
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
Container Registry
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
redox-os
kernel
Commits
d1c0e3b5
Commit
d1c0e3b5
authored
8 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Use flush_all instead of flush for performance
parent
efaeb221
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
context/memory.rs
+45
-5
45 additions, 5 deletions
context/memory.rs
syscall/process.rs
+1
-1
1 addition, 1 deletion
syscall/process.rs
with
46 additions
and
6 deletions
context/memory.rs
+
45
−
5
View file @
d1c0e3b5
...
...
@@ -39,14 +39,22 @@ impl Memory {
pub
fn
map
(
&
mut
self
,
flush
:
bool
,
clear
:
bool
)
{
let
mut
active_table
=
unsafe
{
ActivePageTable
::
new
()
};
let
mut
flush_all
=
false
;
//TODO: Clear pages?
for
page
in
self
.pages
()
{
active_table
.map
(
page
,
self
.flags
);
if
flush
{
active_table
.flush
(
page
);
//active_table.flush(page);
flush_all
=
true
;
}
}
if
flush_all
{
active_table
.flush_all
();
}
if
clear
{
assert!
(
flush
);
unsafe
{
memset
(
self
.start_address
()
.get
()
as
*
mut
u8
,
0
,
self
.size
);
}
...
...
@@ -56,24 +64,40 @@ impl Memory {
pub
fn
unmap
(
&
mut
self
,
flush
:
bool
)
{
let
mut
active_table
=
unsafe
{
ActivePageTable
::
new
()
};
let
mut
flush_all
=
false
;
for
page
in
self
.pages
()
{
active_table
.unmap
(
page
);
if
flush
{
active_table
.flush
(
page
);
//active_table.flush(page);
flush_all
=
true
;
}
}
if
flush_all
{
active_table
.flush_all
();
}
}
pub
fn
remap
(
&
mut
self
,
new_flags
:
EntryFlags
,
flush
:
bool
)
{
let
mut
active_table
=
unsafe
{
ActivePageTable
::
new
()
};
let
mut
flush_all
=
false
;
for
page
in
self
.pages
()
{
active_table
.remap
(
page
,
new_flags
);
if
flush
{
active_table
.flush
(
page
);
//active_table.flush(page);
flush_all
=
true
;
}
}
if
flush_all
{
active_table
.flush_all
();
}
self
.flags
=
new_flags
;
}
...
...
@@ -82,32 +106,48 @@ impl Memory {
//TODO: Calculate page changes to minimize operations
if
new_size
>
self
.size
{
let
mut
flush_all
=
false
;
let
start_page
=
Page
::
containing_address
(
VirtualAddress
::
new
(
self
.start
.get
()
+
self
.size
));
let
end_page
=
Page
::
containing_address
(
VirtualAddress
::
new
(
self
.start
.get
()
+
new_size
-
1
));
for
page
in
Page
::
range_inclusive
(
start_page
,
end_page
)
{
if
active_table
.translate_page
(
page
)
.is_none
()
{
active_table
.map
(
page
,
self
.flags
);
if
flush
{
active_table
.flush
(
page
);
//active_table.flush(page);
flush_all
=
true
;
}
}
}
if
flush_all
{
active_table
.flush_all
();
}
if
clear
{
assert!
(
flush
);
unsafe
{
memset
((
self
.start
.get
()
+
self
.size
)
as
*
mut
u8
,
0
,
new_size
-
self
.size
);
}
}
}
else
if
new_size
<
self
.size
{
let
mut
flush_all
=
false
;
let
start_page
=
Page
::
containing_address
(
VirtualAddress
::
new
(
self
.start
.get
()
+
new_size
));
let
end_page
=
Page
::
containing_address
(
VirtualAddress
::
new
(
self
.start
.get
()
+
self
.size
-
1
));
for
page
in
Page
::
range_inclusive
(
start_page
,
end_page
)
{
if
active_table
.translate_page
(
page
)
.is_some
()
{
active_table
.unmap
(
page
);
if
flush
{
active_table
.flush
(
page
);
//active_table.flush(page);
flush_all
=
true
;
}
}
}
if
flush_all
{
active_table
.flush_all
();
}
}
self
.size
=
new_size
;
...
...
This diff is collapsed.
Click to expand it.
syscall/process.rs
+
1
−
1
View file @
d1c0e3b5
...
...
@@ -49,7 +49,7 @@ pub fn clone(flags: usize) -> Result<usize> {
pub
fn
exit
(
status
:
usize
)
->
!
{
println!
(
"Exit {}"
,
status
);
{
let
contexts
=
context
::
contexts
();
let
context_lock
=
contexts
.current
()
.expect
(
"tried to exit without context"
);
...
...
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