コード例 #1
0
ファイル: cmodes.c プロジェクト: easyaspi314/400plus
int amode_delete(AE_MODE ae_mode) {
	char filenames[2][FILENAME_LENGTH];

	get_amode_filenames(filenames, ae_mode);

	return snapshot_delete(filenames);
}
コード例 #2
0
ファイル: cmodes.c プロジェクト: easyaspi314/400plus
int cmode_delete(int id) {
	char filenames[2][FILENAME_LENGTH];

	get_cmode_filenames(filenames, id);

	return snapshot_delete(filenames);
}
コード例 #3
0
//removes a snapshot with the given id from the list
snapshot* drop(snapshot *snapHead, int id) {
	snapshot *unwantedSnap = get_snapshot(snapHead, id);
	
	if (unwantedSnap == NULL) {
		printf("no such snapshot\n");
		return snapHead;
	}
	else {
		printf("ok\n");
		return snapshot_delete(snapHead, unwantedSnap);	
	}
}
コード例 #4
0
ファイル: cpu.c プロジェクト: SiGe/argos
void cpu_snapshot_tick(cpu_snapshot *cpu) {
    snapshot *snap = 0;

    if (snapshot_create("/proc/stat", &snap) < 0) {
        fprintf(stderr, "Failed to save /proc/stat.\n");
        snapshot_delete(snap);
        return;
    }

    char const *data = snap->data;
    char buf[32];

    while (data) {
        uint64_t t1;
        column(data, 0, buf, 32);

        /* save the total number of jiffies spent in cpu user+system time */
        if (equal(buf, "cpu")) {
            cpu_save_snapshot_to_history(data, snap->time, cpu->main);
        } else if (startswith(buf, "cpu")) {
            int cpu_num = atoi(buf+3);
            cpu_save_snapshot_to_history(data, snap->time, cpu->cpus[cpu_num]);
        }

        /* save the number of context switches */
        if (equal(buf, "ctxt")) {
            column(data, 1, buf, 32);
            t1 = strtoull(buf, 0, 10);

            history_append(cpu->ctxt, snap->time, t1);
        }

        data = next_line(data);
    }

    snapshot_delete(snap);
}
コード例 #5
0
//removes all snapshots from the list that were taken after the one with the given id
snapshot* remove_snapshots(int id, snapshot *snapHead) {
	snapshot *chosenSnap = get_snapshot(snapHead, id);
	snapshot *newSnapHead = snapHead;
	if (chosenSnap == NULL) {
		return newSnapHead;	
	}
	
	chosenSnap = chosenSnap->prev;
	while (chosenSnap != NULL) {
		snapshot *temp = chosenSnap->prev;
		newSnapHead = snapshot_delete(newSnapHead, chosenSnap);
		chosenSnap = temp;
	}	
	
	return newSnapHead;
}