- if (EXPECT_FALSE(_asid[cpu] == Mem_unit::Asid_invalid))
- {
- // FIFO ASID replacement strategy
- unsigned char new_asid = next_asid(cpu);
- Mem_space **bad_guy = &_active_asids.cpu(cpu)[new_asid];
- while (Mem_space *victim = access_once(bad_guy))
- {
- // need ASID replacement
- if (victim == current_mem_space(cpu))
- {
- // do not replace the ASID of the current space
- new_asid = next_asid(cpu);
- bad_guy = &_active_asids.cpu(cpu)[new_asid];
- continue;
- }
-
- //LOG_MSG_3VAL(current(), "ASIDr", new_asid, (Mword)*bad_guy, (Mword)this);
-
- // If the victim is valid and we get a 1 written to the ASID array
- // then we have to reset the ASID of our victim, else the
- // reset_asid function is currently resetting the ASIDs of the
- // victim on a different CPU.
- if (victim != reinterpret_cast<Mem_space*>(~0UL) &&
- mp_cas(bad_guy, victim, reinterpret_cast<Mem_space*>(1)))
- write_now(&victim->_asid[cpu], (Mword)Mem_unit::Asid_invalid);
- break;
- }
-
- _asid[cpu] = new_asid;
- Mem_unit::tlb_flush(new_asid);
- write_now(bad_guy, this);
- }
-
- //LOG_MSG_3VAL(current(), "ASID", (Mword)this, _asid[cpu], (Mword)__builtin_return_address(0));
- return _asid[cpu];