Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
36d964a6
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36d964a6
编写于
11月 22, 2018
作者:
Z
zhangchaoltt
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
framework: set task priority according to sched conf for classic policy (#1940)
上级
32c33065
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
34 addition
and
9 deletion
+34
-9
cyber/scheduler/policy/scheduler_classic.cc
cyber/scheduler/policy/scheduler_classic.cc
+15
-6
cyber/scheduler/policy/scheduler_classic.h
cyber/scheduler/policy/scheduler_classic.h
+4
-0
cyber/scheduler/scheduler_policy_test.cc
cyber/scheduler/scheduler_policy_test.cc
+9
-0
cyber/scheduler/scheduler_test.cc
cyber/scheduler/scheduler_test.cc
+6
-3
未找到文件。
cyber/scheduler/policy/scheduler_classic.cc
浏览文件 @
36d964a6
...
...
@@ -47,10 +47,16 @@ SchedulerClassic::SchedulerClassic() {
apollo
::
cyber
::
proto
::
CyberConfig
cfg
;
// FIXME: later, we will add grp support for classic policy.
if
(
PathExists
(
cfg_file
)
&&
GetProtoFromFile
(
cfg_file
,
&
cfg
))
{
proc_num_
=
cfg
.
scheduler_conf
().
classic_conf
().
groups
(
0
).
processor_num
();
affinity_
=
cfg
.
scheduler_conf
().
classic_conf
().
groups
(
0
).
affinity
();
ParseCpuset
(
cfg
.
scheduler_conf
().
classic_conf
().
groups
(
0
).
cpuset
(),
&
cpuset_
);
auto
&
groups
=
cfg
.
scheduler_conf
().
classic_conf
().
groups
();
proc_num_
=
groups
[
0
].
processor_num
();
affinity_
=
groups
[
0
].
affinity
();
ParseCpuset
(
groups
[
0
].
cpuset
(),
&
cpuset_
);
for
(
auto
&
group
:
groups
)
{
for
(
auto
&
task
:
group
.
tasks
())
{
cr_tasks
[
task
.
name
()]
=
task
;
}
}
}
else
{
// fallback default sched config. To avoid every process launchs
// too many threads, limit to 2 cpus for process w/o explicit config.
...
...
@@ -91,10 +97,13 @@ bool SchedulerClassic::DispatchTask(const std::shared_ptr<CRoutine> cr) {
id_cr_
[
cr
->
id
()]
=
cr
;
}
if
(
cr_tasks
.
find
(
cr
->
name
())
!=
cr_tasks
.
end
())
{
cr
->
set_priority
(
cr_tasks
[
cr
->
name
()].
prio
());
}
// Check if task prio is reasonable.
if
(
cr
->
priority
()
>=
MAX_PRIO
)
{
AWARN
<<
cr
->
name
()
<<
" prio great than MAX_PRIO."
;
AWARN
<<
cr
->
name
()
<<
" prio great than MAX_PRIO."
;
cr
->
set_priority
(
MAX_PRIO
-
1
);
}
...
...
cyber/scheduler/policy/scheduler_classic.h
浏览文件 @
36d964a6
...
...
@@ -20,6 +20,7 @@
#include <memory>
#include <string>
#include <vector>
#include <map>
#include "cyber/scheduler/scheduler.h"
...
...
@@ -27,6 +28,8 @@ namespace apollo {
namespace
cyber
{
namespace
scheduler
{
using
apollo
::
cyber
::
proto
::
ClassicTask
;
class
SchedulerClassic
:
public
Scheduler
{
public:
SchedulerClassic
();
...
...
@@ -39,6 +42,7 @@ class SchedulerClassic : public Scheduler {
void
CreateProcessor
();
bool
DispatchTask
(
const
std
::
shared_ptr
<
CRoutine
>
)
override
;
bool
NotifyProcessor
(
uint64_t
crid
)
override
;
std
::
map
<
std
::
string
,
ClassicTask
>
cr_tasks
;
std
::
string
affinity_
;
std
::
vector
<
int
>
cpuset_
;
...
...
cyber/scheduler/scheduler_policy_test.cc
浏览文件 @
36d964a6
...
...
@@ -20,6 +20,9 @@
#include "cyber/scheduler/policy/choreography.h"
#include "cyber/scheduler/policy/classic.h"
#include "cyber/scheduler/processor.h"
#include "cyber/scheduler/policy/scheduler_classic.h"
#include "cyber/scheduler/policy/scheduler_choreography.h"
#include "cyber/common/global_data.h"
namespace
apollo
{
namespace
cyber
{
...
...
@@ -53,6 +56,12 @@ TEST(SchedulerPolicyTest, classic) {
ctx
->
ShutDown
();
}
TEST
(
SchedulerPolicyTest
,
sched_classic
)
{
GlobalData
::
Instance
()
->
SetProcessGroup
(
"example_classic_sched"
);
Scheduler
*
sched1
=
new
SchedulerClassic
();
sched1
->
ShutDown
();
}
}
// namespace scheduler
}
// namespace cyber
}
// namespace apollo
cyber/scheduler/scheduler_test.cc
浏览文件 @
36d964a6
...
...
@@ -28,17 +28,19 @@ namespace apollo {
namespace
cyber
{
namespace
scheduler
{
auto
sched
=
Scheduler
::
Instance
();
void
proc
()
{}
TEST
(
SchedulerTest
,
create_task
)
{
GlobalData
::
Instance
()
->
SetProcessGroup
(
"example_classic_sched"
);
auto
sched
=
Scheduler
::
Instance
();
cyber
::
Init
(
"scheduler_test"
);
std
::
string
croutine_name
=
"DriverProc"
;
// read example_classic_sched.conf task 'ABC' prio
std
::
string
croutine_name
=
"ABC"
;
EXPECT_TRUE
(
sched
->
CreateTask
(
&
proc
,
croutine_name
));
// create a croutine with the same name
EXPECT_FALSE
(
sched
->
CreateTask
(
&
proc
,
croutine_name
));
auto
task_id
=
GlobalData
::
RegisterTaskName
(
croutine_name
);
EXPECT_TRUE
(
sched
->
NotifyTask
(
task_id
));
EXPECT_TRUE
(
sched
->
RemoveTask
(
croutine_name
));
...
...
@@ -49,6 +51,7 @@ TEST(SchedulerTest, create_task) {
}
TEST
(
SchedulerTest
,
notify_task
)
{
auto
sched
=
Scheduler
::
Instance
();
cyber
::
Init
(
"scheduler_test"
);
std
::
string
name
=
"croutine"
;
auto
id
=
GlobalData
::
RegisterTaskName
(
name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录