Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-11 12:59:58 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
b7d964ee5abb5c216984961577c3d32e7a7adf4f
b7d964ee
2 parents
691b784a
8ab6b576
Merge branch 'srs.master'
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
55 行增加
和
1 行删除
trunk/research/st/srs.c
trunk/research/st/srs.c
查看文件 @
b7d964e
...
...
@@ -52,15 +52,64 @@ int sleep_test()
srs_trace
(
"sleep test: start"
);
srs_trace
(
"1. sleep..."
);
st_utime_t
start
=
st_utime
();
st_usleep
(
sleep_ms
*
1000
);
st_utime_t
end
=
st_utime
();
srs_trace
(
"2. sleep ok"
);
srs_trace
(
"2. sleep ok, sleep=%dus, deviation=%dus"
,
(
int
)(
sleep_ms
*
1000
),
(
int
)(
end
-
start
-
sleep_ms
*
1000
));
srs_trace
(
"sleep test: end"
);
return
0
;
}
st_mutex_t
sleep_work_cond
=
NULL
;
void
*
sleep_deviation_func
(
void
*
arg
)
{
st_mutex_lock
(
sleep_work_cond
);
srs_trace
(
"2. work thread start."
);
int64_t
i
;
for
(
i
=
0
;
i
<
3000000000ULL
;
i
++
)
{
}
st_mutex_unlock
(
sleep_work_cond
);
srs_trace
(
"3. work thread end."
);
return
NULL
;
}
int
sleep_deviation_test
()
{
srs_trace
(
"==================================================="
);
srs_trace
(
"sleep deviation test: start"
);
sleep_work_cond
=
st_mutex_new
();
st_thread_create
(
sleep_deviation_func
,
NULL
,
0
,
0
);
st_mutex_lock
(
sleep_work_cond
);
srs_trace
(
"1. sleep..."
);
st_utime_t
start
=
st_utime
();
// other thread to do some complex work.
st_mutex_unlock
(
sleep_work_cond
);
st_usleep
(
1000
*
1000
);
st_utime_t
end
=
st_utime
();
srs_trace
(
"4. sleep ok, sleep=%dus, deviation=%dus"
,
(
int
)(
sleep_ms
*
1000
),
(
int
)(
end
-
start
-
sleep_ms
*
1000
));
st_mutex_lock
(
sleep_work_cond
);
srs_trace
(
"sleep deviation test: end"
);
st_mutex_destroy
(
sleep_work_cond
);
return
0
;
}
void
*
thread_func
(
void
*
arg
)
{
srs_trace
(
"1. thread run"
);
...
...
@@ -361,6 +410,11 @@ int main(int argc, char** argv)
return
-
1
;
}
if
(
sleep_deviation_test
()
<
0
)
{
srs_trace
(
"sleep_deviation_test failed"
);
return
-
1
;
}
if
(
thread_test
()
<
0
)
{
srs_trace
(
"thread_test failed"
);
return
-
1
;
...
...
请
注册
或
登录
后发表评论