linux 进程线程时间片
首先申明,我是菜鸟.菜到什么程度,大家看看下面的代码.
代码要求:取得1000次单独创建进程的时间.
[code:1:fdac913669]#include
#include
#include
#include
#include
strut timeval {
long tv_sec; /* 秒数 */
long tv_usec; /* 微秒数 */
};
int gettimeofday(struct timeval *tv,struct timezone *tz);
main()
{
struct timeval tpstart,tpend;
float timeuse;
unsigned int i;
gettimeofday(&tpstart,NULL);
for(i=0;i<1000;i++)
pid_t fork();
gettimeofday(&tpend,NULL);
timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec;
timeuse/=1000000;
printf("Used Time:%f\n",timeuse);
exit(0);
}
[/code:1:fdac913669]
取得线程时间:
//线程
不知道该怎么做.因为int pthread_create(pthread_t * thread, pthread_attr_t * attr,
void * (*start_routine)(void *), void * arg)
需要返回一个参数,比如:
int ret;
ret=pthread_create(pthread_t * thread, NULL, void * (*start_routine)(void *), void * arg);
那么时间当中就包含了赋值的时间了.
[b:fdac913669]不知道大家对线程和进程的创建的时间取得有什么好的建议呢?[/b:fdac913669]
aero 回复于:2003-08-10 21:01:44
偶觉得,已经不菜了。
如果你菜,那偶就还是鸟蛋了。
coolhome 回复于:2003-08-10 20:27:00
[code:1:334e6e5b17]
include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
struct timeval {
long tv_sec; /* 秒数 */
long tv_usec; /* 微秒数 */
};
int gettimeofday(struct timeval *tv,struct timezone *tz);
main()
{
struct timeval tpstart,tpend;
float timeuse;
unsigned int i;
int rc;
int p1 = 0;
gettimeofday(&tpstart,NULL);
for(i=0;i&
相关文档:
Service Discovery Protocol(SDP)提供一种能力,让应用程序有方法发现哪种服务可用以及这种服务的特性。
服务发现协议(SDP或Bluetooth SDP)在蓝牙协议栈中对蓝牙环境中的应用程序有特殊的含意,发现哪个服务是可用的和确定这些可用服务的特征。SDP定义了bluetooth client发现可用bluetooth server服务和它们的特征的方法。 ......
/ 根目录
│
├boot/ Linux的内核及系统引导程序所需要的文件目录
│ └grub/ Grub引导器相关的文件
│
&n ......
陈皓 (CSDN)
概述
——
什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional的程序员,makefile还是要懂。这就好像现在有这么多的HTML的编辑器,但如果你想成为一个专业人士,你还是要了解HTML的标识的含义。特别在 ......
除了智能数字终端领域以外,Linux在移动计算平台、智能工业控制、金融业终端系统,甚至军事领域都有着广泛的应用前景。这些Linux被统称为“嵌入式Linux”。下面就来看看都有哪些嵌入式Linux在以上领域纵横驰骋吧!
RT-Linux
这是由美国墨西哥理工学院开发的嵌入式Linux操作系统。到目前为止,RT-Linux已 ......
转自本人个人网站【PHP探路者 http://www.phpwell.com
】
原文地址 http://www.phpwell.com/?p=43
公司内的一台测试服务器原本只是放在公司内网上使用,现需要将测试环境置于Internet上,
以便于客户即时了解项目进展情况。为Linux系统增添一块网卡的过程记录如下:
步骤一:将一块新 ......