Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 如何理解数组中的指针?_C_Arrays_Pointers_Struct_Memory Address - Fatal编程技术网

C 如何理解数组中的指针?

C 如何理解数组中的指针?,c,arrays,pointers,struct,memory-address,C,Arrays,Pointers,Struct,Memory Address,我想得到内核开始执行上述函数的时间,最后我想把它存储在一个缓冲区skbuf中。如果我像上面那样编写代码,那么是否可以将调度时间存储在缓冲区中?请有人帮帮我好吗?我的问题-如果我调用sched_clock();然后它会给出系统的调度时间,但最终如何将其存储在缓冲区中?是否可以使用结构指针存储调度时钟的值?我认为应该是: int netif_rx(struct sk_buff *skb) { struct timeval stamp; if (skb->stamp.tv_sec == 0) d

我想得到内核开始执行上述函数的时间,最后我想把它存储在一个缓冲区skbuf中。如果我像上面那样编写代码,那么是否可以将调度时间存储在缓冲区中?请有人帮帮我好吗?我的问题-如果我调用sched_clock();然后它会给出系统的调度时间,但最终如何将其存储在缓冲区中?是否可以使用结构指针存储调度时钟的值?

我认为应该是:

int netif_rx(struct sk_buff *skb)
{
struct timeval stamp;
if (skb->stamp.tv_sec == 0)
do_gettimeofday(&skb->stamp);
}
我在中找到了这个函数

我想得到内核开始执行上述函数的时间,最后我想把它存储在一个缓冲区skbuf中


sched_clock
不接受参数。是!!没错。但是如何将它存储在skbuf中?你不是说
sku buff
?我在Linux内核中找不到
struct skbuff
。您可以在/Linux/net/core/dev.ct中找到:int netif_rx(struct sk_buff*skb)。上面的api是接收端api,它从发送方接收数据。我想计算它接收数据的时间并将其存储在缓冲区中。您可以在/linux/net/core/dev.c中找到:int netif_rx(struct sk_buff*skb)。上面的api是接收端api,它从发送方接收数据。我想计算它接收数据并将其存储在缓冲区中的时间。你能帮帮我吗?我的代码不就是这么做的吗?我不是内核程序员,我只是在Linux源代码中搜索了
sched_clock
,这是我最好的猜测。你的代码中的sb->tv64是什么??我应该在哪里查找sched_时钟结构?谢谢。修改内核后,那么引导内核的命令是什么?对不起,我不知道。gettimeofday与timestmap相同??我想要一个时间戳。“gettimeofday与timestmap相同”--是的,gettimeofday返回时间戳(通过引用和电视)。@OlegTrakhman是否
gettimeofday
在内核中可用?他的代码在网络驱动程序中。@Barmar:gettimeofday在内核中可用。我必须承认我不喜欢网络/套接字;我刚刚看到struct skb_timeval和struct timeval是相似的,尽管它们的名称,更重要的是它们的字段名(off_sec vs tv_sec)表明它们可能有不同的用途。小心,和往常一样,RTFM:)
__net_timestamp(skb);
static inline void __net_timestamp(struct sk_buff *skb)
 {
         skb->tstamp = ktime_get_real();
 }
int getsocketschedtime(stuct skbuf *sb)
{
    struct timeval tv;
    gettimeofday(&tv, NULL); 
    sb->tstamp.off_sec = tv.tv_sec;
    sb->tstamp.off_usec = tv.tv_usec;
    // ... do smth useful
}