我正在学习常见的lisp,我在理解两个反引号和两个逗号的用法时遇到问题:
``(a ,,(+ 1 2))
Run Code Online (Sandbox Code Playgroud)
我的意思是,我不知道为什么它被评估为:
`(A ,3)
Run Code Online (Sandbox Code Playgroud)
而不是像这样的东西:
`(A 3)
Run Code Online (Sandbox Code Playgroud)
我在解释自己,为了评估表格前面的两个反引号,两个逗号都被"消耗",所以没有一个逗号应该离开,但还有一个.看起来怎么样
``(a ,,(+ 1 2))
Run Code Online (Sandbox Code Playgroud)
仅使用列表和'?
我写了一个循环分叉的程序.子进程执行的唯一操作是增加计数器并退出,而父进程等待它们中的每一个.
我的目标是分别测量父进程和所有子进程的用户和系统时间.我使用times()函数和struct tms成功完成了父进程.令人惊讶的是,对儿童过程的同样方法是行不通的.我在做什么错?如何衡量那些时间?
我也试过getrusage(),我/它失败了.
我的代码:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/times.h>
#include <time.h>
#ifndef COUNT
#define COUNT 100000
#endif
int counter;
int main(){
struct tms time1,time2;
times(&time1);
int count = COUNT;
pid_t pid;
while(count--){
if((pid=fork())<0){
printf("fork error\n");
} else if(pid==0){ /* child */
counter++;
_exit(0);
} else {
waitpid(pid,NULL,0); /*wait()*/
}
}
printf("COUNTER: %d\n",counter);
times(&time2);
long double clktck=sysconf(_SC_CLK_TCK);
double user=(time2.tms_utime-time1.tms_utime)/(double)clktck;
double system=(time2.tms_stime-time1.tms_stime)/(double)clktck;
double cuser=(time2.tms_cutime-time1.tms_cutime)/(double)clktck;
double csystem=(time2.tms_cstime-time1.tms_cstime)/(double)clktck;
printf("USER:%lf\nSYSTEM:%lf\n",user,system);
printf("CUSER:%lf\nCSYSTEM:%lf\n",cuser,csystem);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在阅读Ulrich Drepper的"每个程序员应该了解的关于记忆的内容".在第6部分的开头,theres是一个代码片段:
#include <emmintrin.h>
void setbytes(char *p, int c)
{
__m128i i = _mm_set_epi8(c, c, c, c,
c, c, c, c,
c, c, c, c,
c, c, c, c);
_mm_stream_si128((__m128i *)&p[0], i);
_mm_stream_si128((__m128i *)&p[16], i);
_mm_stream_si128((__m128i *)&p[32], i);
_mm_stream_si128((__m128i *)&p[48], i);
}
Run Code Online (Sandbox Code Playgroud)
在它下面有这样的评论:
假设指针
p已正确对齐,则对此函数的调用将设置所寻址的高速缓存行的所有字节c.写组合逻辑将看到四个生成的movntdq指令,并且只有在执行完最后一条指令后才发出内存的写命令.总而言之,这个代码序列不仅避免了在写入之前读取高速缓存行,还避免了使用可能不需要的数据来缓存高速缓存.
什么错误我是在它被写,它"将设置针对高速缓存行的所有字节到C",但是从我的理解流的intrisics他们绕过缓存功能评论 - 既没有高速缓存的读,也不缓存写入.这段代码如何访问任何缓存行?第二个粗体片段表示相似,即函数"避免在写入之前读取缓存行".如上所述,我没有看到如何以及何时写入缓存.此外,是否需要在缓存写入之前写入缓存?有人可以向我澄清这个问题吗?
我对旧版本的库 testX 有传递性编译依赖。库 testX 不应该是编译依赖,而是 testCompile 依赖。更重要的是,我想依赖于 testX 的新版本,而不是旧版本。
我有一个部分解决方案,它设置了库的正确版本,但它通过覆盖编译依赖项来工作。但是我在编译时留下了不需要的 textX。
compile group: 'x', name: 'testX', version 'new'
Run Code Online (Sandbox Code Playgroud)
我尝试从编译中排除库 testX 并添加显式 testCompile 依赖项,但排除也从 testCompile 中删除了依赖项。
testCompile group: 'x', name: 'testX', version 'new'
configurations {
compile.exclude group: 'x', module: 'X'
}
Run Code Online (Sandbox Code Playgroud)