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
12d58300
Commit
12d58300
authored
2 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Plain Diff
Merge branch 'pin_kmain_contexts' into 'master'
Pin kmain contexts Closes
#111
See merge request
!200
parents
87e1689b
b73922bc
No related branches found
No related tags found
1 merge request
!200
Pin kmain contexts
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/context/list.rs
+15
-4
15 additions, 4 deletions
src/context/list.rs
src/context/mod.rs
+3
-1
3 additions, 1 deletion
src/context/mod.rs
src/lib.rs
+1
-4
1 addition, 4 deletions
src/lib.rs
with
19 additions
and
9 deletions
src/context/list.rs
+
15
−
4
View file @
12d58300
...
@@ -50,10 +50,23 @@ impl ContextList {
...
@@ -50,10 +50,23 @@ impl ContextList {
self
.map
.range
(
range
)
self
.map
.range
(
range
)
}
}
pub
(
crate
)
fn
insert_context_raw
(
&
mut
self
,
id
:
ContextId
)
->
Result
<&
Arc
<
RwLock
<
Context
>>>
{
assert!
(
self
.map
.insert
(
id
,
Arc
::
new
(
RwLock
::
new
(
Context
::
new
(
id
)
?
)))
.is_none
());
Ok
(
self
.map
.get
(
&
id
)
.expect
(
"Failed to insert new context. ID is out of bounds."
))
}
/// Create a new context.
/// Create a new context.
pub
fn
new_context
(
&
mut
self
)
->
Result
<&
Arc
<
RwLock
<
Context
>>>
{
pub
fn
new_context
(
&
mut
self
)
->
Result
<&
Arc
<
RwLock
<
Context
>>>
{
// Zero is not a valid context ID, therefore add 1.
//
// FIXME: Ensure the number of CPUs can't switch between new_context calls.
let
min
=
crate
::
cpu_count
()
+
1
;
self
.next_id
=
core
::
cmp
::
max
(
self
.next_id
,
min
);
if
self
.next_id
>=
super
::
CONTEXT_MAX_CONTEXTS
{
if
self
.next_id
>=
super
::
CONTEXT_MAX_CONTEXTS
{
self
.next_id
=
1
;
self
.next_id
=
min
;
}
}
while
self
.map
.contains_key
(
&
ContextId
::
from
(
self
.next_id
))
{
while
self
.map
.contains_key
(
&
ContextId
::
from
(
self
.next_id
))
{
...
@@ -67,9 +80,7 @@ impl ContextList {
...
@@ -67,9 +80,7 @@ impl ContextList {
let
id
=
ContextId
::
from
(
self
.next_id
);
let
id
=
ContextId
::
from
(
self
.next_id
);
self
.next_id
+=
1
;
self
.next_id
+=
1
;
assert!
(
self
.map
.insert
(
id
,
Arc
::
new
(
RwLock
::
new
(
Context
::
new
(
id
)
?
)))
.is_none
());
self
.insert_context_raw
(
id
)
Ok
(
self
.map
.get
(
&
id
)
.expect
(
"Failed to insert new context. ID is out of bounds."
))
}
}
/// Spawn a context from a function.
/// Spawn a context from a function.
...
...
This diff is collapsed.
Click to expand it.
src/context/mod.rs
+
3
−
1
View file @
12d58300
...
@@ -65,8 +65,10 @@ pub use self::arch::empty_cr3;
...
@@ -65,8 +65,10 @@ pub use self::arch::empty_cr3;
pub
fn
init
()
{
pub
fn
init
()
{
let
mut
contexts
=
contexts_mut
();
let
mut
contexts
=
contexts_mut
();
let
context_lock
=
contexts
.new_context
()
.expect
(
"could not initialize first context"
);
let
id
=
ContextId
::
from
(
crate
::
cpu_id
()
+
1
);
let
context_lock
=
contexts
.insert_context_raw
(
id
)
.expect
(
"could not initialize first context"
);
let
mut
context
=
context_lock
.write
();
let
mut
context
=
context_lock
.write
();
context
.sched_affinity
=
Some
(
crate
::
cpu_id
());
self
::
arch
::
EMPTY_CR3
.call_once
(||
unsafe
{
RmmA
::
table
(
TableKind
::
User
)
});
self
::
arch
::
EMPTY_CR3
.call_once
(||
unsafe
{
RmmA
::
table
(
TableKind
::
User
)
});
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
1
−
4
View file @
12d58300
...
@@ -48,11 +48,8 @@
...
@@ -48,11 +48,8 @@
#![feature(allocator_api)]
#![feature(allocator_api)]
#![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types)]
#![feature(array_chunks)]
#![feature(array_chunks)]
#![feature(asm_const,
asm_sym)]
// TODO: Relax requirements of most asm invocations
#![feature(asm_const)]
// TODO: Relax requirements of most asm invocations
#![feature(bool_to_option)]
#![feature(concat_idents)]
#![feature(concat_idents)]
#![feature(const_btree_new)]
#![feature(const_ptr_offset_from)]
#![feature(core_intrinsics)]
#![feature(core_intrinsics)]
#![feature(integer_atomics)]
#![feature(integer_atomics)]
#![feature(lang_items)]
#![feature(lang_items)]
...
...
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