Ejemplo n.º 1
0
static int __bcache_start(struct bcentry *bce)
{
    struct timespec expires, tmp;

    tssub(bce->lifetime, CN_BRR_BEFORE_EXPIRY_TS, tmp);
    clock_gettime(CLOCK_REALTIME, &bce->add_time);
    tsadd(bce->add_time,
          bce->type == BCE_HOMEREG ? bce->lifetime : tmp,
          expires);
    add_task_abs(&expires, &bce->tqe, _expire);
    xfrm_add_bce(&bce->our_addr, &bce->peer_addr, &bce->coa, 0);
    return 0;
}
Ejemplo n.º 2
0
int bcache_update_expire(struct bcentry *bce)
{
    struct timespec expires;

    clock_gettime(CLOCK_REALTIME, &bce->add_time);
    if (bce->type == BCE_HOMEREG)
        expires = bce->lifetime;
    else {
        bce->type = BCE_CACHED;
        tssub(bce->lifetime, CN_BRR_BEFORE_EXPIRY_TS, expires);
    }
    tsadd(expires, bce->add_time, expires);
    add_task_abs(&expires, &bce->tqe, _expire);
    xfrm_add_bce(&bce->our_addr, &bce->peer_addr, &bce->coa, 1);

    return 0;
}
Ejemplo n.º 3
0
static int
look(pid_t pid)
{
	char pathname[PATH_MAX];
	int rval = 0;
	int fd;
	psinfo_t psinfo;
	prusage_t prusage;
	timestruc_t real, user, sys;
	hrtime_t hrtime;
	prusage_t *pup = &prusage;

	pfirst++;

	if (proc_get_psinfo(pid, &psinfo) < 0)
		return (perr("read psinfo"));

	(void) proc_snprintf(pathname, sizeof (pathname), "/proc/%d/usage",
	    (int)pid);
	if ((fd = open(pathname, O_RDONLY)) < 0)
		return (perr("open usage"));

	if (read(fd, &prusage, sizeof (prusage)) != sizeof (prusage))
		rval = perr("read usage");
	else {
		if (pidarg) {
			hrtime = gethrtime();
			hrt2ts(hrtime, &real);
		} else {
			real = pup->pr_term;
		}
		tssub(&real, &real, &pup->pr_create);
		user = pup->pr_utime;
		sys = pup->pr_stime;
		if (!mflag)
			tsadd(&sys, &sys, &pup->pr_ttime);

		if (!pflag || pfirst > 1)
			(void) fprintf(stderr, "\n");
		if (pflag)
			(void) fprintf(stderr, "%d:\t%.70s\n",
			    (int)psinfo.pr_pid, psinfo.pr_psargs);
		prtime("real", &real);
		prtime("user", &user);
		prtime("sys", &sys);

		if (mflag) {
			prtime("trap", &pup->pr_ttime);
			prtime("tflt", &pup->pr_tftime);
			prtime("dflt", &pup->pr_dftime);
			prtime("kflt", &pup->pr_kftime);
			prtime("lock", &pup->pr_ltime);
			prtime("slp", &pup->pr_slptime);
			prtime("lat", &pup->pr_wtime);
			prtime("stop", &pup->pr_stoptime);
		}
	}

	(void) close(fd);
	return (rval);
}