queue_metric_ = kTouch;
{ // Init all the page locks.
- for (int64 i = 0; i < q_size_; i++)
- pthread_mutex_init(&(pagelocks_[i]), NULL);
+ for (uint64 i = 0; i < q_size_; i++) {
+ pthread_mutex_init(&(pagelocks_[i]), NULL);
+ // Pages start out owned (locked) by Sat::InitializePages.
+ // A locked state indicates that the page state is unknown,
+ // and the lock should not be aquired. As InitializePages creates
+ // the page records, they will be inserted and unlocked, at which point
+ // they are ready to be aquired and filled by worker threads.
+ sat_assert(pthread_mutex_lock(&(pagelocks_[i])) == 0);
+ }
}
{ // Init the random number generator.
// Destructor: Clean-up allocated memory and destroy pthread locks.
FineLockPEQueue::~FineLockPEQueue() {
- int64 i;
+ uint64 i;
for (i = 0; i < q_size_; i++)
pthread_mutex_destroy(&(pagelocks_[i]));
delete[] pagelocks_;
}
// Bucketize the page counts by highest bit set.
- for (int64 i = 0; i < q_size_; i++) {
+ for (uint64 i = 0; i < q_size_; i++) {
uint32 readcount = pages_[i].touch;
int b = 0;
for (b = 0; b < 31; b++) {
- if (readcount < (1 << b))
+ if (readcount < (1u << b))
break;
}
struct page_entry *pe) {
// Traverse through array until finding a page
// that contains the address we want..
- for (int64 i = 0; i < q_size_; i++) {
+ for (uint64 i = 0; i < q_size_; i++) {
uint64 page_addr = pages_[i].paddr;
// This assumes linear vaddr.
if ((page_addr <= paddr) && (page_addr + page_size_ > paddr)) {
uint64 next_try = 1;
// Traverse through array until finding a page meeting given predicate.
- for (int64 i = 0; i < q_size_; i++) {
+ for (uint64 i = 0; i < q_size_; i++) {
uint64 index = (next_try + first_try) % q_size_;
// Go through the loop linear conguentially. We are offsetting by
// 'first_try' so this path will be a different sequence for every