static void pause_query(struct fd_context *ctx, struct fd_hw_query *hq, struct fd_ringbuffer *ring) { int idx = pidx(hq->provider->query_type); assert(idx >= 0); /* query never would have been created otherwise */ assert(hq->period && !hq->period->end); assert(ctx->active_providers & (1 << idx)); hq->period->end = get_sample(ctx, ring, hq->base.type); list_addtail(&hq->period->list, &hq->current_periods); hq->period = NULL; }
static void resume_query(struct fd_context *ctx, struct fd_hw_query *hq, struct fd_ringbuffer *ring) { int idx = pidx(hq->provider->query_type); assert(idx >= 0); /* query never would have been created otherwise */ assert(!hq->period); ctx->active_providers |= (1 << idx); hq->period = util_slab_alloc(&ctx->sample_period_pool); list_inithead(&hq->period->list); hq->period->start = get_sample(ctx, ring, hq->base.type); /* NOTE: util_slab_alloc() does not zero out the buffer: */ hq->period->end = NULL; }
static struct fd_hw_sample * get_sample(struct fd_context *ctx, struct fd_ringbuffer *ring, unsigned query_type) { struct fd_hw_sample *samp = NULL; int idx = pidx(query_type); assume(idx >= 0); /* query never would have been created otherwise */ if (!ctx->sample_cache[idx]) { ctx->sample_cache[idx] = ctx->sample_providers[idx]->get_sample(ctx, ring); } fd_hw_sample_reference(ctx, &samp, ctx->sample_cache[idx]); return samp; }
void whichone(char **arg,int len) { int i; int bg = 0; int pipe = 0; int redir = 0; if(arg[0] == NULL) { fprintf(stderr,"Invalid Command\n"); } for(i=0; i<len; i++) if((strcmp(arg[i],"<") == 0) || (strcmp(arg[i],">") == 0)) redir = 1; for(i=0; i<len; i++) if(strcmp(arg[i],"|") == 0) pipe = 1; if(arg[len-1][strlen(arg[len-1])-1] == '&') { bg = 1; if(arg[len-1][0] == '&') arg[len-1] = NULL; else arg[len-1][strlen(arg[len-1])-1] = '\0'; } if(pipe && !redir) { pipe_func(arg,len); } else if(!pipe && redir) { redir_func(arg,len); } else if(pipe && redir) { redir_pipe_func(arg,len); } else if(strcmp(arg[0],"cd") == 0) { cd(arg,len); } else if(strcmp(arg[0],"pid") == 0) { pidx(arg,len); } else if(arg[0][0]=='h' && arg[0][1]=='i' && arg[0][2]=='s' && arg[0][3]=='t') { hist(arg,len); } else if(arg[0][0]=='!' && arg[0][1]=='h' && arg[0][2]=='i' && arg[0][3]=='s' && arg[0][4]=='t') { hist1(arg,len); } else { other(arg,len,bg); } }