Changeset 22


Ignore:
Timestamp:
Jun 3, 2017, 6:58:06 PM (8 years ago)
Author:
max@…
Message:

cosmetic & typos again

Location:
trunk/kernel/mm
Files:
2 edited

Legend:

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

    r18 r22  
    3939#include <page.h>
    4040
    41 
    42 
    4341////////////////////////////////////////
    4442inline void page_init( page_t   * page )
     
    4947        page->mapper   = NULL;
    5048        page->private  = 0;
    51     page->refcount = 0;
     49        page->refcount = 0;
    5250        spinlock_init( &page->lock );
    5351        list_entry_init( &page->list );
     
    5856                           uint16_t   value )
    5957{
    60     hal_atomic_or( (uint32_t *)&page->flags , (uint32_t)value );
     58        hal_atomic_or( (uint32_t *)&page->flags , (uint32_t)value );
    6159}
    6260
     
    6563                             uint16_t   value )
    6664{
    67     hal_atomic_and( (uint32_t *)&page->flags , ~((uint32_t)value) );
     65        hal_atomic_and( (uint32_t *)&page->flags , ~((uint32_t)value) );
    6866}
    6967
     
    7270                            uint16_t   value )
    7371{
    74     return (bool_t)(page->flags & value);
     72        return (bool_t)(page->flags & value);
    7573}
    7674
     
    8078        bool_t done = false;
    8179
    82     ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    83 
    84     // lock the PPM dirty_list
     80        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
     81
     82        // lock the PPM dirty_list
    8583        spinlock_lock( &ppm->dirty_lock );
    8684
    8785        if( !page_is_flag( page , PG_DIRTY ) )
    8886        {
    89         // set dirty flag in page descriptor
     87                // set dirty flag in page descriptor
    9088                page_set_flag( page , PG_DIRTY );
    9189
    92         // register page in PPM dirty list
     90                // register page in PPM dirty list
    9391                list_add_first( &ppm->dirty_root , &page->list );
    9492                done = true;
    9593        }
    9694
    97     // unlock the PPM dirty_list
     95        // unlock the PPM dirty_list
    9896        spinlock_unlock( &ppm->dirty_lock );
    9997
     
    106104        bool_t done = false;
    107105
    108     ppm_t * ppm = &LOCAL_CLUSTER->ppm;
    109 
    110     // lock the dirty_list
     106        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
     107
     108        // lock the dirty_list
    111109        spinlock_lock( &ppm->dirty_lock );
    112110
    113111        if( page_is_flag( page , PG_DIRTY) )
    114112        {
    115         // clear dirty flag in page descriptor
     113                // clear dirty flag in page descriptor
    116114                page_clear_flag( page , PG_DIRTY );
    117115
    118         // remove page from PPM dirty list
     116                // remove page from PPM dirty list
    119117                list_unlink( &page->list );
    120118                done = true;
    121119        }
    122120
    123     // unlock the dirty_list
     121        // unlock the dirty_list
    124122        spinlock_unlock( &ppm->dirty_lock );
    125123
     
    132130        page_t   * page;
    133131        mapper_t * mapper;
    134     uint32_t   index;
    135     ppm_t    * ppm = &LOCAL_CLUSTER->ppm;
    136 
    137     // lock the dirty_list
     132        uint32_t   index;
     133        ppm_t    * ppm = &LOCAL_CLUSTER->ppm;
     134
     135        // lock the dirty_list
    138136        spinlock_lock( &ppm->dirty_lock );
    139137
     
    142140                page = LIST_FIRST( &ppm->dirty_root ,  page_t , list );
    143141
    144         // unlock the dirty_list
    145             spinlock_unlock( &ppm->dirty_lock );
     142                // unlock the dirty_list
     143                spinlock_unlock( &ppm->dirty_lock );
    146144
    147145                mapper = page->mapper;
    148         index  = page->index;
    149 
    150         // lock the page
     146                index  = page->index;
     147
     148                // lock the page
    151149                page_lock( page );
    152150
    153         // sync the page
     151                // sync the page
    154152                mapper_sync_page( mapper , index , page );
    155153
    156         // unlock the page
     154                // unlock the page
    157155                page_unlock( page );
    158156
    159         // lock the dirty_list
    160             spinlock_lock( &ppm->dirty_lock );
    161         }
    162 
    163     // unlock the dirty_list
     157                // lock the dirty_list
     158                spinlock_lock( &ppm->dirty_lock );
     159        }
     160
     161        // unlock the dirty_list
    164162        spinlock_unlock( &ppm->dirty_lock );
    165163
    166 } // end sync_all_pages()
     164}
    167165
    168166///////////////////////////////
    169167void page_lock( page_t * page )
    170168{
    171     // take the spinlock protecting the PG_LOCKED flag
     169        // take the spinlock protecting the PG_LOCKED flag
    172170        spinlock_lock( &page->lock );
    173171
    174172        if( page_is_flag( page , PG_LOCKED ) )  // page is already locked
    175173        {
    176         // get pointer on calling thread
    177         thread_t * thread = CURRENT_THREAD;
    178 
    179         // register thread in the page waiting queue
    180         xlist_add_last( XPTR( local_cxy , &page->wait_root ),
    181                         XPTR( local_cxy , &thread->wait_list ) );
    182 
    183         // release the spinlock
     174                // get pointer on calling thread
     175                thread_t * thread = CURRENT_THREAD;
     176
     177                // register thread in the page waiting queue
     178                xlist_add_last( XPTR( local_cxy , &page->wait_root ),
     179                                XPTR( local_cxy , &thread->wait_list ) );
     180
     181                // release the spinlock
    184182                spinlock_unlock( &page->lock );
    185183
    186         // deschedule the calling thread
    187         thread_block( thread , THREAD_BLOCKED_PAGE );
     184                // deschedule the calling thread
     185                thread_block( thread , THREAD_BLOCKED_PAGE );
    188186                sched_yield();
    189187        }
    190188        else                                    // page is not locked
    191189        {
    192         // set the PG_LOCKED flag
     190                // set the PG_LOCKED flag
    193191                page_set_flag( page , PG_LOCKED );
    194192
    195         // release the spinlock
     193                // release the spinlock
    196194                spinlock_unlock( &page->lock );
    197195        }
     
    201199void page_unlock( page_t * page )
    202200{
    203     // take the spinlock protecting the PG_LOCKED flag
     201        // take the spinlock protecting the PG_LOCKED flag
    204202        spinlock_lock( &page->lock );
    205203
    206     // check the page waiting list
     204        // check the page waiting list
    207205        bool_t is_empty = xlist_is_empty( XPTR( local_cxy , &page->wait_root ) );
    208206
    209207        if( is_empty == false )    // at least one waiting thread => resume it
    210     {
    211         // get an extended pointer on the first waiting thread
    212         xptr_t root_xp   = XPTR( local_cxy , &page->wait_root );
    213         xptr_t thread_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list );
    214 
    215         // reactivate the first waiting thread
    216         thread_unblock( thread_xp , THREAD_BLOCKED_PAGE );
    217     }
     208        {
     209                // get an extended pointer on the first waiting thread
     210                xptr_t root_xp   = XPTR( local_cxy , &page->wait_root );
     211                xptr_t thread_xp = XLIST_FIRST_ELEMENT( root_xp , thread_t , wait_list );
     212
     213                // reactivate the first waiting thread
     214                thread_unblock( thread_xp , THREAD_BLOCKED_PAGE );
     215        }
    218216        else                      // no waiting thread => clear the PG_LOCKED flag
    219217        {
    220         page_clear_flag( page , PG_LOCKED );
    221     }
    222 
    223     // release the spinlock
     218                page_clear_flag( page , PG_LOCKED );
     219        }
     220
     221        // release the spinlock
    224222        spinlock_unlock( &page->lock );
    225223}
     
    228226inline void page_refcount_up( page_t *page )
    229227{
    230     hal_atomic_inc( &page->refcount );
     228        hal_atomic_inc( &page->refcount );
    231229}
    232230
     
    234232inline void page_refcount_down( page_t *page )
    235233{
    236     hal_atomic_dec( &page->refcount );
     234        hal_atomic_dec( &page->refcount );
    237235}
    238236
     
    246244
    247245        if( dst->order != src->order )
    248     {
    249         printk("\n[PANIC] in %s : src size != dst size\n", __FUNCTION__ );
    250         hal_core_sleep();
    251     }
     246        {
     247                printk("\n[PANIC] in %s : src size != dst size\n", __FUNCTION__ );
     248                hal_core_sleep();
     249        }
    252250
    253251        size = (1 << dst->order) * CONFIG_PPM_PAGE_SIZE;
     
    289287}
    290288
    291 
    292 
    293 
    294 
    295 
  • trunk/kernel/mm/page.h

    r18 r22  
    8888
    8989/*************************************************************************************
    90  * This function set one or several flags in page descriptor flags.
     90 * This function sets one or several flags in page descriptor flags.
    9191 * @ page    : pointer to page descriptor.
    9292 * @ value   : all non zero bits in value will be set.
     
    9696
    9797/*************************************************************************************
    98  * This function reset one or several flags in page descriptor flags.
     98 * This function clears one or several flags in page descriptor flags.
    9999 * @ page    : pointer to page descriptor.
    100100 * @ value   : all non zero bits in value will be cleared.
     
    104104
    105105/*************************************************************************************
    106  * This function test the value of one or several flags in page descriptor flags.
     106 * This function tests the value of one or several flags in page descriptor flags.
    107107 * @ page    : pointer to page descriptor.
    108108 * @ value   : all non zero bits will be tested.
     
    114114/*************************************************************************************
    115115 * This function synchronizes (i.e. update the disk) all dirty pages in a cluster.
    116  * It scan the PPM dirty list, that should be empty when this operation is completed.
     116 * It scans the PPM dirty list, that should be empty when this operation is completed.
    117117 ************************************************************************************/
    118118void sync_all_pages();
    119119
    120120/*************************************************************************************
    121  * This function set the PG_DIRTY flag in the page descriptor,
    122  * and register the page in the dirty list in PPM.
     121 * This function sets the PG_DIRTY flag in the page descriptor,
     122 * and registers the page in the dirty list in PPM.
    123123 * @ page     : pointer on page descriptor.
    124124 * @ returns true if page was not dirty / returns false if page was dirty
     
    127127
    128128/*************************************************************************************
    129  * This function reset the PG_DIRTY flag in the page descriptor,
    130  * and remove the page from the dirty list in PPM.
     129 * This function resets the PG_DIRTY flag in the page descriptor,
     130 * and removes the page from the dirty list in PPM.
    131131 * @ page     : pointer on page descriptor.
    132132 * @ returns true if page was dirty / returns false if page was not dirty
     
    135135
    136136/*************************************************************************************
    137  * This function makes a local copy of the content of a src page  to a dst page.
     137 * This function makes a local copy of the content of a src page to a dst page.
    138138 * @ dst      : pointer on destination page descriptor.
    139139 * @ src      : pointer on source page descriptor.
     
    143143
    144144/*************************************************************************************
    145  * This function reset to 0 all bytes in a given page.
     145 * This function resets to 0 all bytes in a given page.
    146146 * @ page     : pointer on page descriptor.
    147147 ************************************************************************************/
     
    157157
    158158/*************************************************************************************
    159  * This blocking function reset the PG_LOCKED flag on the page, if there is no
    160  * other waiting thread. IF there is waiting thread(s), it activates the first
     159 * This blocking function resets the PG_LOCKED flag on the page, if there is no
     160 * other waiting thread. If there is waiting thread(s), it activates the first
    161161 * waiting thread without modifying the PG_LOCKED flag.
    162162 * @ page     : pointer on page descriptor.
     
    165165
    166166/*************************************************************************************
    167  * This blocking function atomically increment the page refcount.
     167 * This blocking function atomically increments the page refcount.
    168168 * @ page     : pointer on page descriptor.
    169169 ************************************************************************************/
     
    171171
    172172/*************************************************************************************
    173  * This blocking function atomically decrement the page refcount.
     173 * This blocking function atomically decrements the page refcount.
    174174 * @ page     : pointer on page descriptor.
    175175 ************************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.