免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2006 | 回复: 5
打印 上一主题 下一主题

[新手入门] 在aix下有没有类似hp-ux下times函数,多谢各位指教。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-05-21 18:00 |只看该作者 |倒序浏览
在aix下有没有类似hp-ux下times函数,多谢各位指教。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2003-05-22 08:52 |只看该作者

在aix下有没有类似hp-ux下times函数,多谢各位指教。

你得先说说HP下的time函数的作用阿!

论坛徽章:
0
3 [报告]
发表于 2003-05-22 11:51 |只看该作者

在aix下有没有类似hp-ux下times函数,多谢各位指教。

当然有啊:)

论坛徽章:
0
4 [报告]
发表于 2003-05-22 14:01 |只看该作者

在aix下有没有类似hp-ux下times函数,多谢各位指教。

老农大侠,函数名呢?????

论坛徽章:
0
5 [报告]
发表于 2003-05-22 14:05 |只看该作者

在aix下有没有类似hp-ux下times函数,多谢各位指教。

Technical Reference: Base Operating System and Extensions, Volume 1
gettimer, settimer, restimer, stime, or time Subroutine

Purpose
Gets or sets the current value for the specified systemwide timer.

Library
Standard C Library (libc.a)

Syntax

#include <sys/time.h>;
#include <sys/types.h>;

int gettimer( TimerType, Value)
timer_t TimerType;
struct timestruc_t * Value;


#include <sys/timers.h>;
#include <sys/types.h>;

int gettimer( TimerType, Value)
timer_t TimerType;
struct itimerspec * Value;

int settimer(TimerType,  TimePointer)
int TimerType;
const struct timestruc_t *TimePointer;

int restimer(TimerType,  Resolution,  MaximumValue)
int TimerType;
struct timestruc_t *Resolution, *MaximumValue;

int stime( Tp)
long *Tp;


#include <sys/types.h>;

time_t time(Tp)
time_t *Tp;
Description
The settimer subroutine is used to set the current value of the TimePointer parameter for the systemwide timer, specified by the TimerType parameter.

When the gettimer subroutine is used with the function prototype in sys/timers.h, then except for the parameters, the gettimer subroutine is identical to the getinterval (getinterval, incinterval, absinterval, resinc, resabs, alarm, ualarm, getitimer or setitimer Subroutine) subroutine. Use of the getinterval subroutine is recommended, unless the gettimer subroutine is required for a standards-conformant application. The description and semantics of the gettimer subroutine are subject to change between releases, pending changes in the draft standard upon which the current gettimer subroutine description is based.

When the gettimer subroutine is used with the function prototype in /sys/timers.h, the gettimer subroutine returns an itimerspec structure to the pointer specified by the Value parameter. The it_value member of the itimerspec structure represents the amount of time in the current interval before the timer (specified by the TimerType parameter) expires, or a zero interval if the timer is disabled. The members of the pointer specified by the Value parameter are subject to the resolution of the timer.

When the gettimer subroutine is used with the function prototype in sys/time.h, the gettimer subroutine returns a timestruc structure to the pointer specified by the Value parameter. This structure holds the current value of the system wide timer specified by the Value parameter.

The resolution of any timer can be obtained by the restimer subroutine. The Resolution parameter represents the resolution of the specified timer. The MaximumValue parameter represents the maximum possible timer value. The value of these parameters are the resolution accepted by the settimer subroutine.

Note
If a nonprivileged user attempts to submit a fine granularity timer (that is, a timer request of less than 10 milliseconds), the timer request is raised to 10 milliseconds.
The time subroutine returns the time in seconds since the Epoch (that is, 00:00:00 GMT, January 1, 1970). The Tp parameter points to an area where the return value is also stored. If the Tp parameter is a null pointer, no value is stored.

The stime subroutine is implemented to provide compatibility with older AIX, AT&T System V, and BSD systems. It calls the settimer subroutine using the TIMEOFDAY timer.

Parameters

Value Points to a structure of type itimerspec.
TimerType Specifies the systemwide timer:
TIMEOFDAY
(POSIX system clock timer) This timer represents the time-of-day clock for the system. For this timer, the values returned by the gettimer subroutine and specified by the settimer subroutine represent the amount of time since 00:00:00 GMT, January 1, 1970.  
TimePointer Points to a structure of type struct timestruc_t.
Resolution The resolution of a specified timer.
MaximumValue The maximum possible timer value.
Tp Points to a structure containing the time in seconds.

Return Values
The gettimer, settimer, restimer, and stime subroutines return a value of 0 (zero) if the call is successful. A return value of -1 indicates an error occurred, and errno is set.

The time subroutine returns the value of time in seconds since Epoch. Otherwise, a value of ((time_t) - 1) is returned and the errno global variable is set to indicate the error.

Error Codes
If an error occurs in the gettimer, settimer, restimer, or stime subroutine, a return value of - 1 is received and the errno global variable is set to one of the following error codes:

EINVAL The TimerType parameter does not specify a known systemwide timer, or the TimePointer parameter of the settimer subroutine is outside the range for the specified systemwide timer.
EFAULT A parameter address referenced memory that was not valid.
EIO An error occurred while accessing the timer device.
EPERM The requesting process does not have the appropriate privilege to set the specified timer.

If the time subroutine is unsuccessful, a return value of -1 is received and the errno global variable is set to the following:

EFAULT A parameter address referenced memory that was not valid.

Related Information
The asctime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, clock (clock Subroutine) subroutine, ctime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, difftime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, getinterval (getinterval, incinterval, absinterval, resinc, resabs, alarm, ualarm, getitimer or setitimer Subroutine) subroutine, gmtime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, localtime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, mktime (ctime, localtime, gmtime, mktime, difftime, asctime, or tzset Subroutine) subroutine, strftime subroutine, strptime subroutine, utime subroutine.

List of Time Data Manipulation Services in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices.

Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

论坛徽章:
0
6 [报告]
发表于 2003-05-22 14:15 |只看该作者

在aix下有没有类似hp-ux下times函数,多谢各位指教。

安装MAN时把TECHREF也装上,以后系统提供的函数可以用
man 2 ...来看

比如 man 2 time, man 2 printf
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP