Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
3bb6a7c2
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
3bb6a7c2
编写于
4月 09, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 09, 2023
浏览文件
操作
浏览文件
下载
差异文件
!861 feat: support EDF
Merge pull request !861 from zhangdengyu/supportEDF0404
上级
bb23f33d
cf4228a3
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
169 addition
and
46 deletion
+169
-46
porting/liteos_a/user/include/sched.h
porting/liteos_a/user/include/sched.h
+143
-0
porting/liteos_a/user/src/internal/pthread_impl.h
porting/liteos_a/user/src/internal/pthread_impl.h
+3
-0
porting/liteos_a/user/src/sched/sched_getparam.c
porting/liteos_a/user/src/sched/sched_getparam.c
+1
-6
porting/liteos_a/user/src/sched/sched_setparam.c
porting/liteos_a/user/src/sched/sched_setparam.c
+1
-2
porting/liteos_a/user/src/sched/sched_setscheduler.c
porting/liteos_a/user/src/sched/sched_setscheduler.c
+1
-2
porting/liteos_a/user/src/thread/pthread_attr_setschedparam.c
...ing/liteos_a/user/src/thread/pthread_attr_setschedparam.c
+8
-6
porting/liteos_a/user/src/thread/pthread_attr_setschedpolicy.c
...ng/liteos_a/user/src/thread/pthread_attr_setschedpolicy.c
+1
-2
porting/liteos_a/user/src/thread/pthread_create.c
porting/liteos_a/user/src/thread/pthread_create.c
+5
-11
porting/liteos_a/user/src/thread/pthread_getschedparam.c
porting/liteos_a/user/src/thread/pthread_getschedparam.c
+1
-2
porting/liteos_a/user/src/thread/pthread_setschedparam.c
porting/liteos_a/user/src/thread/pthread_setschedparam.c
+1
-10
porting/liteos_a/user/src/thread/pthread_setschedprio.c
porting/liteos_a/user/src/thread/pthread_setschedprio.c
+4
-5
未找到文件。
porting/liteos_a/user/include/sched.h
0 → 100644
浏览文件 @
3bb6a7c2
#ifndef _SCHED_H
#define _SCHED_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <features.h>
#define __NEED_struct_timespec
#define __NEED_pid_t
#define __NEED_time_t
#ifdef _GNU_SOURCE
#define __NEED_size_t
#endif
#include <bits/alltypes.h>
struct
sched_param
{
union
{
int
sched_priority
;
int
sched_runtime
;
};
int
sched_deadline
;
int
sched_period
;
};
int
sched_get_priority_max
(
int
);
int
sched_get_priority_min
(
int
);
int
sched_getparam
(
pid_t
,
struct
sched_param
*
);
int
sched_getscheduler
(
pid_t
);
int
sched_rr_get_interval
(
pid_t
,
struct
timespec
*
);
int
sched_setparam
(
pid_t
,
const
struct
sched_param
*
);
int
sched_setscheduler
(
pid_t
,
int
,
const
struct
sched_param
*
);
int
sched_yield
(
void
);
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
#define SCHED_BATCH 3
#define SCHED_IDLE 5
#define SCHED_DEADLINE 6
#define SCHED_RESET_ON_FORK 0x40000000
#ifdef _GNU_SOURCE
#define CSIGNAL 0x000000ff
#define CLONE_NEWTIME 0x00000080
#define CLONE_VM 0x00000100
#define CLONE_FS 0x00000200
#define CLONE_FILES 0x00000400
#define CLONE_SIGHAND 0x00000800
#define CLONE_PIDFD 0x00001000
#define CLONE_PTRACE 0x00002000
#define CLONE_VFORK 0x00004000
#define CLONE_PARENT 0x00008000
#define CLONE_THREAD 0x00010000
#define CLONE_NEWNS 0x00020000
#define CLONE_SYSVSEM 0x00040000
#define CLONE_SETTLS 0x00080000
#define CLONE_PARENT_SETTID 0x00100000
#define CLONE_CHILD_CLEARTID 0x00200000
#define CLONE_DETACHED 0x00400000
#define CLONE_UNTRACED 0x00800000
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_NEWCGROUP 0x02000000
#define CLONE_NEWUTS 0x04000000
#define CLONE_NEWIPC 0x08000000
#define CLONE_NEWUSER 0x10000000
#define CLONE_NEWPID 0x20000000
#define CLONE_NEWNET 0x40000000
#define CLONE_IO 0x80000000
int
clone
(
int
(
*
)(
void
*
),
void
*
,
int
,
void
*
,
...);
int
unshare
(
int
);
int
setns
(
int
,
int
);
void
*
memcpy
(
void
*
__restrict
,
const
void
*
__restrict
,
size_t
);
int
memcmp
(
const
void
*
,
const
void
*
,
size_t
);
void
*
memset
(
void
*
,
int
,
size_t
);
void
*
calloc
(
size_t
,
size_t
);
void
free
(
void
*
);
typedef
struct
cpu_set_t
{
unsigned
long
__bits
[
128
/
sizeof
(
long
)];
}
cpu_set_t
;
int
__sched_cpucount
(
size_t
,
const
cpu_set_t
*
);
int
sched_getcpu
(
void
);
int
sched_getaffinity
(
pid_t
,
size_t
,
cpu_set_t
*
);
int
sched_setaffinity
(
pid_t
,
size_t
,
const
cpu_set_t
*
);
#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
(((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
#define CPU_ISSET_S(i, size, set) __CPU_op_S(i, size, set, &)
#define __CPU_op_func_S(func, op) \
static __inline void __CPU_##func##_S(size_t __size, cpu_set_t *__dest, \
const cpu_set_t *__src1, const cpu_set_t *__src2) \
{ \
size_t __i; \
for (__i=0; __i<__size/sizeof(long); __i++) \
((unsigned long *)__dest)[__i] = ((unsigned long *)__src1)[__i] \
op ((unsigned long *)__src2)[__i] ; \
}
__CPU_op_func_S
(
AND
,
&
)
__CPU_op_func_S
(
OR
,
|
)
__CPU_op_func_S
(
XOR
,
^
)
#define CPU_AND_S(a,b,c,d) __CPU_AND_S(a,b,c,d)
#define CPU_OR_S(a,b,c,d) __CPU_OR_S(a,b,c,d)
#define CPU_XOR_S(a,b,c,d) __CPU_XOR_S(a,b,c,d)
#define CPU_COUNT_S(size,set) __sched_cpucount(size,set)
#define CPU_ZERO_S(size,set) memset(set,0,size)
#define CPU_EQUAL_S(size,set1,set2) (!memcmp(set1,set2,size))
#define CPU_ALLOC_SIZE(n) (sizeof(long) * ( (n)/(8*sizeof(long)) \
+ ((n)%(8*sizeof(long)) + 8*sizeof(long)-1)/(8*sizeof(long)) ) )
#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1,CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)
#define CPU_SETSIZE 128
#define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set)
#define CPU_CLR(i, set) CPU_CLR_S(i,sizeof(cpu_set_t),set)
#define CPU_ISSET(i, set) CPU_ISSET_S(i,sizeof(cpu_set_t),set)
#define CPU_AND(d,s1,s2) CPU_AND_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_OR(d,s1,s2) CPU_OR_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_XOR(d,s1,s2) CPU_XOR_S(sizeof(cpu_set_t),d,s1,s2)
#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t),set)
#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set)
#define CPU_EQUAL(s1,s2) CPU_EQUAL_S(sizeof(cpu_set_t),s1,s2)
#endif
#if _REDIR_TIME64
__REDIR
(
sched_rr_get_interval
,
__sched_rr_get_interval_time64
);
#endif
#ifdef __cplusplus
}
#endif
#endif
porting/liteos_a/user/src/internal/pthread_impl.h
浏览文件 @
3bb6a7c2
...
...
@@ -83,6 +83,9 @@ enum {
#define _a_sched __u.__i[3*__SU+1]
#define _a_policy __u.__i[3*__SU+2]
#define _a_prio __u.__i[3*__SU+3]
#define _a_runtime __u.__i[3*__SU+3]
#define _a_deadline __u.__i[3*__SU+4]
#define _a_period __u.__i[3*__SU+5]
#define _m_type __u.__i[0]
#define _m_lock __u.__vi[1]
#define _m_waiters __u.__vi[2]
...
...
porting/liteos_a/user/src/sched/sched_getparam.c
浏览文件 @
3bb6a7c2
...
...
@@ -13,12 +13,7 @@ int sched_getparam(pid_t pid, struct sched_param *param)
}
memset
(
param
,
0
,
sizeof
(
struct
sched_param
));
r
=
__syscall
(
SYS_sched_getparam
,
pid
,
MUSL_TYPE_PROCESS
);
if
(
r
>=
0
)
{
param
->
sched_priority
=
r
;
r
=
0
;
}
r
=
__syscall
(
SYS_sched_getparam
,
pid
,
param
,
MUSL_TYPE_PROCESS
);
exit:
return
__syscall_ret
(
r
);
}
porting/liteos_a/user/src/sched/sched_setparam.c
浏览文件 @
3bb6a7c2
...
...
@@ -11,8 +11,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param)
goto
exit
;
}
r
=
__syscall
(
SYS_sched_setparam
,
pid
,
param
->
sched_priority
,
MUSL_TYPE_PROCESS
);
r
=
__syscall
(
SYS_sched_setparam
,
pid
,
param
,
MUSL_TYPE_PROCESS
);
exit:
return
__syscall_ret
(
r
);
}
porting/liteos_a/user/src/sched/sched_setscheduler.c
浏览文件 @
3bb6a7c2
...
...
@@ -11,8 +11,7 @@ int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param)
goto
exit
;
}
r
=
__syscall
(
SYS_sched_setscheduler
,
pid
,
sched
,
param
->
sched_priority
,
MUSL_TYPE_PROCESS
);
r
=
__syscall
(
SYS_sched_setscheduler
,
pid
,
sched
,
param
,
MUSL_TYPE_PROCESS
);
exit:
return
__syscall_ret
(
r
);
}
porting/liteos_a/user/src/thread/pthread_attr_setschedparam.c
浏览文件 @
3bb6a7c2
...
...
@@ -2,10 +2,12 @@
int
pthread_attr_setschedparam
(
pthread_attr_t
*
restrict
a
,
const
struct
sched_param
*
restrict
param
)
{
if
(
param
->
sched_priority
<
0
||
param
->
sched_priority
>
PTHREAD_PRIORITY_LOWEST
)
{
return
EINVAL
;
}
a
->
_a_prio
=
param
->
sched_priority
;
return
0
;
if
((
a
->
_a_policy
==
SCHED_RR
||
a
->
_a_policy
==
SCHED_FIFO
)
&&
(
param
->
sched_priority
<
0
||
param
->
sched_priority
>
PTHREAD_PRIORITY_LOWEST
))
{
return
EINVAL
;
}
a
->
_a_prio
=
param
->
sched_priority
;
a
->
_a_deadline
=
param
->
sched_deadline
;
a
->
_a_period
=
param
->
sched_period
;
return
0
;
}
porting/liteos_a/user/src/thread/pthread_attr_setschedpolicy.c
浏览文件 @
3bb6a7c2
...
...
@@ -2,10 +2,9 @@
int
pthread_attr_setschedpolicy
(
pthread_attr_t
*
a
,
int
policy
)
{
if
(
policy
!=
SCHED_RR
&&
policy
!=
SCHED_FIFO
)
{
if
(
policy
!=
SCHED_RR
&&
policy
!=
SCHED_FIFO
&&
policy
!=
SCHED_DEADLINE
)
{
return
EINVAL
;
}
a
->
_a_policy
=
policy
;
return
0
;
}
porting/liteos_a/user/src/thread/pthread_create.c
浏览文件 @
3bb6a7c2
...
...
@@ -217,8 +217,8 @@ weak_alias(dummy_tsd, __pthread_tsd_main);
int
__pthread_init_and_check_attr
(
const
pthread_attr_t
*
restrict
attrp
,
pthread_attr_t
*
attr
)
{
int
policy
=
0
;
struct
sched_param
param
=
{
0
};
int
policy
=
0
;
struct
sched_param
param
=
{
0
};
int
c11
=
(
attrp
==
__ATTRP_C11_THREAD
);
int
ret
;
...
...
@@ -233,14 +233,8 @@ int __pthread_init_and_check_attr(const pthread_attr_t *restrict attrp, pthread_
if
(
ret
)
return
ret
;
attr
->
_a_policy
=
policy
;
attr
->
_a_prio
=
param
.
sched_priority
;
}
if
(
attr
->
_a_policy
!=
SCHED_RR
&&
attr
->
_a_policy
!=
SCHED_FIFO
)
{
return
EINVAL
;
}
if
(
attr
->
_a_prio
<
0
||
attr
->
_a_prio
>
PTHREAD_PRIORITY_LOWEST
)
{
return
EINVAL
;
attr
->
_a_deadline
=
param
.
sched_deadline
;
attr
->
_a_period
=
param
.
sched_period
;
}
return
0
;
...
...
@@ -372,7 +366,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
__restore_sigs
(
&
set
);
__release_ptc
();
ret
=
__syscall
(
SYS_sched_setscheduler
,
new
->
tid
,
attr
.
_a_policy
,
attr
.
_a_prio
,
MUSL_TYPE_THREAD
);
new
->
tid
,
attr
.
_a_policy
,
&
attr
.
_a_prio
,
MUSL_TYPE_THREAD
);
}
if
(
ret
<
0
)
{
...
...
porting/liteos_a/user/src/thread/pthread_getschedparam.c
浏览文件 @
3bb6a7c2
...
...
@@ -10,9 +10,8 @@ int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param
if
(
!
t
->
tid
)
{
r
=
ESRCH
;
}
else
{
r
=
__syscall
(
SYS_sched_getparam
,
t
->
tid
,
MUSL_TYPE_THREAD
);
r
=
__syscall
(
SYS_sched_getparam
,
t
->
tid
,
param
,
MUSL_TYPE_THREAD
);
if
(
r
>=
0
)
{
param
->
sched_priority
=
r
;
r
=
__syscall
(
SYS_sched_getscheduler
,
t
->
tid
,
MUSL_TYPE_THREAD
);
if
(
r
>=
0
)
{
*
policy
=
r
;
...
...
porting/liteos_a/user/src/thread/pthread_setschedparam.c
浏览文件 @
3bb6a7c2
...
...
@@ -4,19 +4,10 @@
int
pthread_setschedparam
(
pthread_t
t
,
int
policy
,
const
struct
sched_param
*
param
)
{
int
r
;
if
(
policy
!=
SCHED_RR
&&
policy
!=
SCHED_FIFO
)
{
return
EINVAL
;
}
if
(
param
->
sched_priority
<
0
||
param
->
sched_priority
>
PTHREAD_PRIORITY_LOWEST
)
{
return
EINVAL
;
}
sigset_t
set
;
__block_app_sigs
(
&
set
);
LOCK
(
t
->
killlock
);
r
=
!
t
->
tid
?
ESRCH
:
-
__syscall
(
SYS_sched_setscheduler
,
t
->
tid
,
policy
,
param
->
sched_priority
,
MUSL_TYPE_THREAD
);
r
=
!
t
->
tid
?
ESRCH
:
-
__syscall
(
SYS_sched_setscheduler
,
t
->
tid
,
policy
,
param
,
MUSL_TYPE_THREAD
);
UNLOCK
(
t
->
killlock
);
__restore_sigs
(
&
set
);
return
r
;
...
...
porting/liteos_a/user/src/thread/pthread_setschedprio.c
浏览文件 @
3bb6a7c2
...
...
@@ -4,15 +4,14 @@
int
pthread_setschedprio
(
pthread_t
t
,
int
prio
)
{
int
r
;
if
(
prio
<
0
||
prio
>
PTHREAD_PRIORITY_LOWEST
)
{
return
EINVAL
;
}
struct
sched_param
param
=
{
.
sched_priority
=
prio
,
};
sigset_t
set
;
__block_app_sigs
(
&
set
);
LOCK
(
t
->
killlock
);
r
=
!
t
->
tid
?
ESRCH
:
-
__syscall
(
SYS_sched_setparam
,
t
->
tid
,
prio
,
MUSL_TYPE_THREAD
);
r
=
!
t
->
tid
?
ESRCH
:
-
__syscall
(
SYS_sched_setparam
,
t
->
tid
,
&
param
,
MUSL_TYPE_THREAD
);
UNLOCK
(
t
->
killlock
);
__restore_sigs
(
&
set
);
return
r
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录