Ejemplo n.º 1
0
void mcs_rwlock::acquire_read() 
{
    /* attempt to CAS first. If no writers around, or no intervening
     * add'l readers, we're done
     */
    if(!attempt_read()) {
        /* There seem to be writers around, or other readers intervened in our
         * attempt_read() above.
         * Join the queue and wait for them to leave 
         */
        {
            CRITICAL_SECTION(cs, (parent_lock*) this);
            _add_when_writer_leaves(READER);
        }
        membar_enter();
    }
}
Ejemplo n.º 2
0
int main()
{
  REPORT_START_CMPLT;

  /* try reading/writing kernel memory */
  attempt_read((int *)0x500000);
  attempt_write((int *)0x500000);
  
  /* try writing rodata section */
  attempt_write((int *)array);

  /* try writing text secion */
  attempt_write((int *)main);

  REPORT_END_SUCCESS;

  exit(0);
}