Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kernel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
kernel
Commits
ef919f3d
Verified
Commit
ef919f3d
authored
Dec 22, 2018
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement EINTR for anything using wait_queue
parent
46a63256
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
10 deletions
+18
-10
src/event.rs
src/event.rs
+2
-2
src/scheme/debug.rs
src/scheme/debug.rs
+3
-1
src/scheme/user.rs
src/scheme/user.rs
+4
-1
src/sync/wait_map.rs
src/sync/wait_map.rs
+1
-0
src/sync/wait_queue.rs
src/sync/wait_queue.rs
+8
-6
No files found.
src/event.rs
View file @
ef919f3d
...
...
@@ -7,7 +7,7 @@ use context;
use
scheme
::{
self
,
SchemeId
};
use
sync
::
WaitQueue
;
use
syscall
::
data
::
Event
;
use
syscall
::
error
::{
Error
,
Result
,
EBADF
,
ESRCH
};
use
syscall
::
error
::{
Error
,
Result
,
EBADF
,
E
INTR
,
E
SRCH
};
int_like!
(
EventQueueId
,
AtomicEventQueueId
,
usize
,
AtomicUsize
);
...
...
@@ -25,7 +25,7 @@ impl EventQueue {
}
pub
fn
read
(
&
self
,
events
:
&
mut
[
Event
])
->
Result
<
usize
>
{
Ok
(
self
.queue
.receive_into
(
events
,
true
))
self
.queue
.receive_into
(
events
,
true
)
.ok_or
(
Error
::
new
(
EINTR
))
}
pub
fn
write
(
&
self
,
events
:
&
[
Event
])
->
Result
<
usize
>
{
...
...
src/scheme/debug.rs
View file @
ef919f3d
...
...
@@ -68,7 +68,9 @@ impl Scheme for DebugScheme {
*
handles
.get
(
&
id
)
.ok_or
(
Error
::
new
(
EBADF
))
?
};
Ok
(
INPUT
.call_once
(
init_input
)
.receive_into
(
buf
,
flags
&
O_NONBLOCK
!=
O_NONBLOCK
))
INPUT
.call_once
(
init_input
)
.receive_into
(
buf
,
flags
&
O_NONBLOCK
!=
O_NONBLOCK
)
.ok_or
(
Error
::
new
(
EINTR
))
}
/// Write the `buffer` to the `file`
...
...
src/scheme/user.rs
View file @
ef919f3d
...
...
@@ -168,7 +168,10 @@ impl UserInner {
pub
fn
read
(
&
self
,
buf
:
&
mut
[
u8
])
->
Result
<
usize
>
{
let
packet_buf
=
unsafe
{
slice
::
from_raw_parts_mut
(
buf
.as_mut_ptr
()
as
*
mut
Packet
,
buf
.len
()
/
mem
::
size_of
::
<
Packet
>
())
};
Ok
(
self
.todo
.receive_into
(
packet_buf
,
self
.flags
&
O_NONBLOCK
!=
O_NONBLOCK
)
*
mem
::
size_of
::
<
Packet
>
())
self
.todo
.receive_into
(
packet_buf
,
self
.flags
&
O_NONBLOCK
!=
O_NONBLOCK
)
.map
(|
count
|
count
*
mem
::
size_of
::
<
Packet
>
())
.ok_or
(
Error
::
new
(
EINTR
))
}
pub
fn
write
(
&
self
,
buf
:
&
[
u8
])
->
Result
<
usize
>
{
...
...
src/sync/wait_map.rs
View file @
ef919f3d
...
...
@@ -27,6 +27,7 @@ impl<K, V> WaitMap<K, V> where K: Clone + Ord {
if
let
Some
(
value
)
=
self
.receive_nonblock
(
key
)
{
return
value
;
}
//TODO: use false from wait condition to indicate EINTR
let
_
=
self
.condition
.wait
();
}
}
...
...
src/sync/wait_queue.rs
View file @
ef919f3d
...
...
@@ -28,20 +28,22 @@ impl<T> WaitQueue<T> {
self
.inner
.lock
()
.is_empty
()
}
pub
fn
receive
(
&
self
)
->
T
{
pub
fn
receive
(
&
self
)
->
Option
<
T
>
{
loop
{
if
let
Some
(
value
)
=
self
.inner
.lock
()
.pop_front
()
{
return
value
;
return
Some
(
value
);
}
if
!
self
.condition
.wait
()
{
return
None
;
}
let
_
=
self
.condition
.wait
();
}
}
pub
fn
receive_into
(
&
self
,
buf
:
&
mut
[
T
],
block
:
bool
)
->
usize
{
pub
fn
receive_into
(
&
self
,
buf
:
&
mut
[
T
],
block
:
bool
)
->
Option
<
usize
>
{
let
mut
i
=
0
;
if
i
<
buf
.len
()
&&
block
{
buf
[
i
]
=
self
.receive
();
buf
[
i
]
=
self
.receive
()
?
;
i
+=
1
;
}
...
...
@@ -57,7 +59,7 @@ impl<T> WaitQueue<T> {
}
}
i
Some
(
i
)
}
pub
fn
send
(
&
self
,
value
:
T
)
->
usize
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment