POSIX-Data Structure

strcut sigevent

The <signal.h> header shall define the sigeventstructure, which shall include at least the following members:

struct sigevent {
    int           sigev_notify;            //Notification type.
    int           sigev_signo;            //Signal number.
    union sigval  sigev_value;             //Signal value.
    void         (*sigev_notify_function)(union sigval); //Notification function.
    pthread_attr_t *sigev_notify_attributes;  //Notification attributes.
}; 

sigev_notify

sigev_notify 的取值范围如下,只有3种情况(对应的宏在<signal.h>中定义)。

SIGEV_NONE
事件发生时,什么也不做.
SIGEV_SIGNAL
事件发生时,将sigev_signo 指定的信号(A queued signal)发送给指定的进程.
SIGEV_THREAD
事件发生时,内核会(在此进程内)以sigev_notification_attributes为线程属性创建一个线程,并且让它执行sigev_notify_function
传入sigev_value作为为一个参数.

sigev_signo

sigev_notify = SIGEV_SIGNAL 时使用,指定信号的种别(number).

sigev_value

sigev_notify = SIGEV_THREAD 时使用,作为sigev_notify_function 的参数.

union sigval
{
    int sival_int;
    void *sival_ptr;
};  

(*sigev_notify_function)(union sigval)

函数指针(指向通知执行函数),在sigev_notify = SIGEV_THREAD 时使用, 其他情况下置为NULL.

sigev_notify_attributes

指向线程属性的指针,在sigev_notify = SIGEV_THREAD 时使用,指定创建线程的属性, 其他情况下置为NULL.


struct timespec

The <time.h> header shall declare the timespecstructure, which shall include at least the following members:

struct timespec
{
    time_t tv_sec;        /* Seconds */
    long   tv_nsec;        /* Nanoseconds(纳秒:十亿分之一秒) */
};

strcut itimerspec

The <time.h> header shall also declare the itimerspecstructure, which shall include at least the following members:

struct itimerspec
{
    struct timespec it_interval;  /* Timer interval(timer循环时间间隔) */
    struct timespec it_value;     /* Initial expiration(timer初次到期时间) */
};

clockid_t

clockid_tis used for clock ID type in the clock and timer functions, 取值范围如下(前4个是POSIX定义的,灰色部分为Linux的扩展),

/* Identifier for system-wide realtime clock, Setting this clock requires appropriate privileges */
#define CLOCK_REALTIME        0
/* Monotonic system-wide clock, Clock that cannot be set and represents monotonic time since some unspecified starting point  */
#define CLOCK_MONOTONIC        1
/* High-resolution timer from the CPU.  */
#define 2
/* Thread-specific CPU-time clock.  */
#define CLOCK_THREAD_CPUTIME_ID    3
/* Monotonic system-wide clock, not adjusted for frequency scaling.  */
#define CLOCK_MONOTONIC_RAW        4
/* Identifier for system-wide realtime clock, updated only on ticks.  */
#define CLOCK_REALTIME_COARSE    5
/* Monotonic system-wide clock, updated only on ticks.  */
#define CLOCK_MONOTONIC_COARSE    6

CLOCK_REALTIME : 这种时钟表示的是绝对时间, 指的是从1970年1月1月0:00到目前经过多少秒, 相当于你的linux系统中显示的时间, 所以这个时间是可以更改的, 当系统的时钟源被改变,或者系统管理员重置了系统时间之后,这种类型的时钟可以得到相应的调整, 对设定为此类型的timer是有影响的.

CLOCK_MONOTONIC : 这种时钟表示的是相对时间, 其值对通过累积时钟节拍(嘀嗒)计算出来的, 不受时钟源等的影响, 从系统启动这一刻起开始计时, 如果你想计算出在一台计算机上不受重启的影响,两个事件发生的间隔时间的话,那么它将是最好的选择。

CLOCK_PROCESS_CPUTIME_ID : 本进程到当前代码系统CPU花费的时间

CLOCK_THREAD_CPUTIME_ID : 本线程到当前代码系统CPU花费的时间

 

 

时间: 2024-08-02 07:03:39

POSIX-Data Structure的相关文章

What is “passive data structure” in Android/Java?

From the Android developer web link: http://developer.android.com/reference/android/content/Intent.html, you can find that it says "It (Intent) is basically a passive data structure holding an abstract description of an action to be performed."

[LeetCode] 211. Add and Search Word - Data structure design Java

题目: Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one le

170. Two Sum III - Data structure design

Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure.find - Find if there exists any pair of numbers which sum is equal to the value. For example, add(1); ad

LeetCode OJ:Add and Search Word - Data structure design(增加以及搜索单词)

Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter

[leedcode 211] Add and Search Word - Data structure design

Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter

uva 11995 - I Can Guess the Data Structure!

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=3146&mosmsg=Submission+received+with+ID+14262472 I Can Guess the Data Structure! There is a bag-like data structure, supporti

[LeetCode] All O`one Data Structure 全O(1)的数据结构

Implement a data structure supporting the following operations: Inc(Key) - Inserts a new key with value 1. Or increments an existing key by 1. Key is guaranteed to be a non-empty string. Dec(Key) - If Key's value is 1, remove it from the data structu

hdu-5929 Basic Data Structure(双端队列+模拟)

题目链接: Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 207    Accepted Submission(s): 41 Problem Description Mr. Frog learned a basic data structure recently, which is called

211. Add and Search Word - Data structure design

就是trie 1 public class WordDictionary { 2 public class TrieNode { 3 public TrieNode[] child; 4 public char curChar; 5 public boolean isLeaf; 6 7 public TrieNode() { 8 child = new TrieNode[26]; 9 isLeaf = false; 10 } 11 } 12 13 TrieNode root; 14 15 pub

(Data structure)Implement Trie And Add and Search Word

Implement Trie (Prefix Tree) Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs are consist of lowercase letters a-z solution: class TrieNode { // Initialize your data structure here. boolean isEnd; Trie