Re: setup the PMU to generate an interrupt on x number of LLC misses
Emanuel Berg <embe8573@student.uu.se> writes:
> "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?
It will block until there is a non-zero amount of data to read. It's
always possible to read the file descriptor; it just sounds like in your
case there's usually nothing to get out of it. The way you're calling
select(2) right now:
> retval = select(fd + 1, &rfds, NULL, NULL, &tv);
Will use the timeout value stored in tv, which you have set to rate *
1000, which is in microseconds. I'm not sure what command line you're
using so I'm not sure how quickly it's timing out for you. I would
suggest finding out two things:
1. What happens if you pass in NULL instead of &tv? This will block
indefinitely until there is data ready.
2. Have you ever gotten valid data out of the file handle when not using
the select call? If not, I would solve that issue first.
I've used the select call before and found it a bit tricky (but it does
work!), but you've already gotten past my pitfall, which was that I
passed in `1` instead of `fd+1` and nothing worked until I fixed that.
--
Devrin Talen <dct23@cornell.edu>
Reply to: