Example #1
0
void task_complete_event(resch_task_t *rt) {

	unsigned long flags;
	unsigned long timestamp;
	resch_task_t *next;
	resch_task_t temp;
	unsigned long tempa;

	tempa = linux_timestamp_microsec(0);	

	if (rt == NULL) {
		printk(KERN_WARNING "(task_complete) rt == NULL???\n");
		return;
	}

	timestamp = jiffies; //linux_timestamp_microsec(0);

	active_queue_lock(rt->cpu_id, &flags);
	next = active_next_prio_task(rt);
	active_queue_unlock(rt->cpu_id, &flags);

	if (next != NULL) {
		store_event(rt, next, NULL, NULL, 0, timestamp, FALSE, FALSE);
	}
	else {
		temp.pid = 0;
		store_event(rt, &temp, NULL, NULL, 0, timestamp, FALSE, FALSE);
	}

	mikaoverhead += linux_timestamp_microsec(0)-tempa;

}
Example #2
0
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
		     int fd, int group_fd, unsigned long flags)
{
	int errno_saved = errno;

	if (store_event(attr, pid, cpu, fd, group_fd, flags))
		die("test attr FAILED");

	errno = errno_saved;
}
Example #3
0
void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
		     int fd, int group_fd, unsigned long flags)
{
	int errno_saved = errno;

	if ((fd != -1) && store_event(attr, pid, cpu, fd, group_fd, flags)) {
		pr_err("test attr FAILED");
		exit(128);
	}

	errno = errno_saved;
}
Example #4
0
void task_release_event(resch_task_t *rt) {

	unsigned long flags;
	unsigned long timestamp;
	resch_task_t *curr;
	resch_task_t temp;
	unsigned long tempa;

	tempa = linux_timestamp_microsec(0);

	if (rt == NULL) {
		printk(KERN_WARNING "(task_release) rt == NULL???\n");
		return;
	}

	timestamp = jiffies; //linux_timestamp_microsec(0);

	active_queue_lock(rt->cpu_id, &flags);
	curr = active_highest_prio_task(rt->cpu_id);
	active_queue_unlock(rt->cpu_id, &flags);

	if (curr != NULL) {
		if (rt->prio > curr->prio) { // This means context switch!
			store_event(curr, rt, NULL, NULL, 1, timestamp, FALSE, FALSE);
		}
		else { // Released task is not preempting, just register a task release (but no context switch)...
			store_event(rt, rt, NULL, NULL, 2, timestamp, FALSE, FALSE);
		}
	}
	else { // Ready queue was empty (besides the new task), means that idle task was running...
		temp.pid = 0;
		store_event(&temp, rt, NULL, NULL, 1, timestamp, FALSE, FALSE);
	}

	mikaoverhead += linux_timestamp_microsec(0)-tempa;

}
Example #5
0
int main(int argc, char* argv[])
{
	int i = 0;
	int fd;
	struct pollfd* mfds = (struct pollfd*)calloc(1, sizeof(struct pollfd));
	int mfd_count = 0;
	int nr;
	struct input_event event;
	int store_fd;
	char** dev_name;

	if(argc < 2)
	{
		fprintf(stderr, "error input\n");
		usage(argv[0]);
		exit(-1);
	}

	if(strcmp(argv[1], "a1") == 0)
	{
		dev_name = dev_name_a1;
	}
	else if (strcmp(argv[1], "a310") == 0)
	{
		dev_name = dev_name_a310;
	} 
	else if (strcmp(argv[1], "a810") == 0)
	{
		dev_name = dev_name_a810;
	}
	else 
	{
		fprintf(stderr, "error input argv[1]: %s\n", argv[1]);
		usage(argv[0]);
		exit(-1);
	}
	 
	i = 0;
	while(dev_name[i] != NULL)
	{

		printf("open %s\n", dev_name[i]);
		fd = open_dev(dev_name[i]);
		if(fd > 0)
		{
			struct pollfd* new_mfds = (struct pollfd*)realloc(mfds, sizeof(struct pollfd)*(mfd_count + 1));

			if(new_mfds == NULL)
			{
				fprintf(stderr, "realloc out of memeory\n");
				return -1;
			}

			mfds = new_mfds;

			mfds[i].fd = fd;
			mfds[i].events = POLLIN;
			mfd_count++;
		}

		i++;
	}

	//open store file
	store_fd = open(gen_filename(), O_RDWR|O_CREAT);
	if(store_fd < 0)
	{
		fprintf(stderr, "fail to open record file\n");
		exit(-1);
	}
	
	while(1)
	{

		nr = poll(mfds, mfd_count, 0);
		if(nr <= 0)
			continue;

		for(i = 0; i < mfd_count; i++)
		{
			if(mfds[i].revents == POLLIN)
			{
				int ret = read(mfds[i].fd, &event, sizeof(event));
				if(ret == sizeof(event))
				{
					show_event(&event);
					store_event(store_fd, &event);
				}

			}

		}

	}
	return 0;
}