Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
0ae2c49e
提交
0ae2c49e
authored
4月 08, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quietly apply params if thread is going to be parked
上级
1a67259d
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
16 行删除
+21
-16
thread_rt.rs
src/thread_rt.rs
+21
-16
没有找到文件。
src/thread_rt.rs
浏览文件 @
0ae2c49e
...
...
@@ -167,7 +167,7 @@ impl Builder {
thread_init_internal
(
tx
,
park_on_errors
);
f
()
})
?
;
let
tid
=
thread_init_external
(
rx
,
&
rt_params
)
?
;
let
tid
=
thread_init_external
(
rx
,
&
rt_params
,
park_on_errors
)
?
;
Ok
(
Task
{
name
,
handle
,
...
...
@@ -218,7 +218,7 @@ impl Builder {
thread_init_internal
(
tx
,
park_on_errors
);
f
()
})
?
;
let
tid
=
thread_init_external
(
rx
,
&
rt_params
)
?
;
let
tid
=
thread_init_external
(
rx
,
&
rt_params
,
park_on_errors
)
?
;
Ok
(
ScopedTask
{
name
,
handle
,
...
...
@@ -290,8 +290,8 @@ impl<T> Task<T> {
}
/// Applies new real-time params
pub
fn
apply_rt_params
(
&
mut
self
,
rt_params
:
RTParams
)
->
Result
<
()
>
{
if
let
Err
(
e
)
=
apply_thread_params
(
self
.tid
,
&
rt_params
)
{
let
_
=
apply_thread_params
(
self
.tid
,
&
self
.rt_params
);
if
let
Err
(
e
)
=
apply_thread_params
(
self
.tid
,
&
rt_params
,
false
)
{
let
_
=
apply_thread_params
(
self
.tid
,
&
self
.rt_params
,
false
);
return
Err
(
e
);
}
self
.rt_params
=
rt_params
;
...
...
@@ -351,8 +351,8 @@ impl<'scope, T> ScopedTask<'scope, T> {
}
/// Applies new real-time params
pub
fn
apply_rt_params
(
&
mut
self
,
rt_params
:
RTParams
)
->
Result
<
()
>
{
if
let
Err
(
e
)
=
apply_thread_params
(
self
.tid
,
&
rt_params
)
{
let
_
=
apply_thread_params
(
self
.tid
,
&
self
.rt_params
);
if
let
Err
(
e
)
=
apply_thread_params
(
self
.tid
,
&
rt_params
,
false
)
{
let
_
=
apply_thread_params
(
self
.tid
,
&
self
.rt_params
,
false
);
return
Err
(
e
);
}
self
.rt_params
=
rt_params
;
...
...
@@ -454,13 +454,14 @@ fn thread_init_internal(
fn
thread_init_external
(
rx_tid
:
oneshot
::
Receiver
<
(
libc
::
c_int
,
oneshot
::
Sender
<
bool
>
)
>
,
params
:
&
RTParams
,
quiet
:
bool
,
)
->
Result
<
libc
::
c_int
>
{
let
(
tid
,
tx_ok
)
=
rx_tid
.recv
()
?
;
if
tid
<
0
{
tx_ok
.send
(
false
)
.map_err
(|
e
|
Error
::
IO
(
e
.to_string
()))
?
;
return
Err
(
Error
::
RTGetTId
(
tid
));
}
if
let
Err
(
e
)
=
apply_thread_params
(
tid
,
params
)
{
if
let
Err
(
e
)
=
apply_thread_params
(
tid
,
params
,
quiet
)
{
tx_ok
.send
(
false
)
.map_err
(|
e
|
Error
::
IO
(
e
.to_string
()))
?
;
return
Err
(
e
);
}
...
...
@@ -468,7 +469,7 @@ fn thread_init_external(
Ok
(
tid
)
}
fn
apply_thread_params
(
tid
:
libc
::
c_int
,
params
:
&
RTParams
)
->
Result
<
()
>
{
fn
apply_thread_params
(
tid
:
libc
::
c_int
,
params
:
&
RTParams
,
quiet
:
bool
)
->
Result
<
()
>
{
if
!
is_realtime
()
{
return
Ok
(());
}
...
...
@@ -480,10 +481,12 @@ fn apply_thread_params(tid: libc::c_int, params: &RTParams) -> Result<()> {
}
let
res
=
libc
::
sched_setaffinity
(
tid
,
std
::
mem
::
size_of
::
<
libc
::
cpu_set_t
>
(),
&
cpuset
);
if
res
!=
0
{
eprintln!
(
"Error setting CPU affinity: {}"
,
std
::
io
::
Error
::
last_os_error
()
);
if
!
quiet
{
eprintln!
(
"Error setting CPU affinity: {}"
,
std
::
io
::
Error
::
last_os_error
()
);
}
return
Err
(
Error
::
RTSchedSetAffinity
(
res
));
}
}
...
...
@@ -499,10 +502,12 @@ fn apply_thread_params(tid: libc::c_int, params: &RTParams) -> Result<()> {
)
};
if
res
!=
0
{
eprintln!
(
"Error setting scheduler: {}"
,
std
::
io
::
Error
::
last_os_error
()
);
if
!
quiet
{
eprintln!
(
"Error setting scheduler: {}"
,
std
::
io
::
Error
::
last_os_error
()
);
}
return
Err
(
Error
::
RTSchedSetSchduler
(
res
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论