[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: setup the PMU to generate an interrupt on x number of LLC misses



"Devrin Talen" <dct23@cornell.edu> writes:

> To block on accesses to a file until it actually has
> data for you try reading up on the `select` call:
>
>      % man 2 select

That would be great because that is exactly what I
need. However I didn't get it to work. I always get
"No data." for the below code, but it doesn't wait for
the timeout, it is just no data instantly on every
iteration. Does select(2) really block until there is
data, or does it block until it is possible to read
the fd?

The whole program: http://user.it.uu.se/~embe8573/llc-select/

  // select
  fd_set rfds;
  FD_ZERO(&rfds);
  FD_SET(0,  &rfds);
  FD_SET(fd, &rfds);

  int retval;

  long long old_count = -1;
  long long     count =  0;

  struct timeval tv;
  tv.tv_sec = 0;
  tv.tv_usec = rate*1000;

  while (count < max_misses) {
    retval = select(fd + 1, &rfds, NULL, NULL, &tv);
    if (retval == -1) { std::cerr << "Can't select()!" << std::endl; }
    else if (retval) {
      std::cout << "Data available! ";
      read(fd, &count, sizeof(count));
      if (count != old_count) { std::cout << "LLC misses: " << count << std::endl; }
    }
    else { std::cout << "No data." << std::endl; }
  }

-- 
underground experts united


Reply to: