Ignore:
Timestamp:
Oct 5, 2018, 12:01:52 AM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/mm/mapper.c

    r457 r567  
    3636#include <kmem.h>
    3737#include <kcm.h>
     38#include <ppm.h>
    3839#include <page.h>
    3940#include <cluster.h>
    4041#include <vfs.h>
    4142#include <mapper.h>
     43
    4244
    4345//////////////////////////////////////////////
     
    8385
    8486    // initialize mapper lock
    85     rwlock_init(  &mapper->lock );
     87    rwlock_init(  &mapper->lock , LOCK_MAPPER_STATE );
    8688
    8789    // initialize waiting threads xlist (empty)
     
    153155
    154156    // take mapper lock in READ_MODE
    155     rwlock_rd_lock( &mapper->lock );
     157    rwlock_rd_acquire( &mapper->lock );
    156158
    157159    // search page in radix tree
     
    163165
    164166        // release the lock in READ_MODE and take it in WRITE_MODE
    165         rwlock_rd_unlock( &mapper->lock );
    166         rwlock_wr_lock( &mapper->lock );
     167        rwlock_rd_release( &mapper->lock );
     168        rwlock_wr_acquire( &mapper->lock );
    167169
    168170        // second test on missing page because the page status can have been modified
     
    189191                printk("\n[ERROR] in %s : thread %x cannot allocate a page in cluster %x\n",
    190192                       __FUNCTION__ , this->trdid , local_cxy );
    191                 rwlock_wr_unlock( &mapper->lock );
     193                rwlock_wr_release( &mapper->lock );
    192194                return NULL;
    193195            }
     
    204206
    205207            // release mapper lock from WRITE_MODE
    206             rwlock_wr_unlock( &mapper->lock );
     208            rwlock_wr_release( &mapper->lock );
    207209
    208210            if( error )
     
    239241        {
    240242            // release mapper lock from WRITE_MODE
    241             rwlock_wr_unlock( &mapper->lock );
     243            rwlock_wr_release( &mapper->lock );
    242244
    243245            // wait load completion
    244             while( 1 )
     246            while( page_is_flag( page , PG_INLOAD ) == false )
    245247            {
    246                 // exit waiting loop when loaded
    247                 if( page_is_flag( page , PG_INLOAD ) == false ) break;
    248 
    249                 // deschedule
     248                // deschedule without blocking
    250249                sched_yield("waiting page loading");
    251250            }
     
    254253    else                          // page available in mapper
    255254    {
    256         rwlock_rd_unlock( &mapper->lock );
     255        rwlock_rd_release( &mapper->lock );
    257256    }
    258257
     
    284283
    285284    // take mapper lock in WRITE_MODE
    286     rwlock_wr_lock( &mapper->lock );
     285    rwlock_wr_acquire( &mapper->lock );
    287286
    288287    // remove physical page from radix tree
     
    290289
    291290    // release mapper lock from WRITE_MODE
    292     rwlock_wr_unlock( &mapper->lock );
     291    rwlock_wr_release( &mapper->lock );
    293292
    294293    // release page to PPM
     
    372371        else
    373372        {
    374             page_do_dirty( page );
     373            ppm_page_do_dirty( page );
    375374            hal_copy_from_uspace( map_ptr , buf_ptr , page_count );
    376375        }
     
    485484            dst_ptr = base_ptr + page_offset;
    486485
    487             page_do_dirty( page );
     486            ppm_page_do_dirty( page );
    488487        }
    489488
Note: See TracChangeset for help on using the changeset viewer.