Changeset 561 for trunk


Ignore:
Timestamp:
Sep 21, 2018, 10:26:47 PM (3 years ago)
Author:
nicolas.van.phan@…
Message:

Remove y_max in all functions except dqdt_init()

Location:
trunk/kernel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/fs/ramfs.c

    r457 r561  
    3838    xptr_t    root_inode_xp;   // unused                     
    3939 
    40     cxy_t     cxy = vfs_cluster_random_select();
     40    cxy_t     cxy = cluster_random_select();
    4141
    4242    // create VFS dentry and VFS inode for RAMFS root directory
  • trunk/kernel/fs/vfs.c

    r530 r561  
    11241124//////////////////////////////////////////////////////////////////////////////////////////
    11251125
    1126 /////////////////////////////////
    1127 cxy_t vfs_cluster_random_select( void )
    1128 {
    1129     uint32_t  x_max     = LOCAL_CLUSTER->x_max; // [FIXME]
    1130     uint32_t  y_max     = LOCAL_CLUSTER->y_max; // [FIXME]
    1131     uint32_t  y_width   = LOCAL_CLUSTER->y_width;
    1132     uint32_t  index     = ( hal_get_cycles() + hal_get_gid() ) % (x_max * y_max); // [FIXME]
    1133     uint32_t  x         = index / y_max; // [FIXME]
    1134     uint32_t  y         = index % y_max; // [FIXME]
    1135 
    1136     return (x<<y_width) + y;
    1137 }
    1138 
    11391126
    11401127//////////////////////////////////////////////////////////////////////////
     
    15121499
    15131500            // select a cluster for missing inode
    1514             child_cxy = vfs_cluster_random_select();
     1501            child_cxy = cluster_random_select();
    15151502 
    15161503            // insert a new child dentry/inode in inode tree
  • trunk/kernel/fs/vfs.h

    r484 r561  
    517517
    518518/******************************************************************************************
    519  * This function randomly selects a cluster for a new inode.
    520  ******************************************************************************************
    521  * @ returns the selected cluster identifier.
    522  *****************************************************************************************/
    523 cxy_t vfs_cluster_random_select( void );
    524 
    525 /******************************************************************************************
    526519 * This function returns in a kernel buffer allocated by the caller function,
    527520 * the pathname of a file/dir identified by an extended pointer on the inode.
  • trunk/kernel/kern/cluster.c

    r557 r561  
    4545#include <process.h>
    4646#include <dqdt.h>
     47#include <cluster_info.h>
    4748
    4849/////////////////////////////////////////////////////////////////////////////////////
     
    212213} // end cluster_init()
    213214
     215/////////////////////////////////
     216cxy_t cluster_random_select( void )
     217{
     218    uint32_t  x_size;
     219    uint32_t  y_size;
     220    uint32_t  y_width;
     221    uint32_t  index;
     222    uint32_t  x;
     223    uint32_t  y;
     224
     225    do {
     226        x_size     = LOCAL_CLUSTER->x_size;
     227        y_size     = LOCAL_CLUSTER->y_size;
     228        y_width   = LOCAL_CLUSTER->y_width;
     229        index     = ( hal_get_cycles() + hal_get_gid() ) % (x_size * y_size);
     230        x         = index / y_size;
     231        y         = index % y_size;
     232    } while ( cluster_info_is_active( LOCAL_CLUSTER->cluster_info[x][y] ) == 0 );
     233
     234    return (x<<y_width) + y;
     235}
     236
    214237////////////////////////////////////////
    215238bool_t cluster_is_undefined( cxy_t cxy )
  • trunk/kernel/kern/cluster.h

    r557 r561  
    176176error_t cluster_init( boot_info_t * info );
    177177
     178/******************************************************************************************
     179 * This function randomly selects a cluster.
     180 ******************************************************************************************
     181 * @ returns the selected cluster identifier.
     182 *****************************************************************************************/
     183cxy_t cluster_random_select( void );
     184
    178185/******************************************************************************************
    179186 * This function checks the validity of a cluster identifier.
  • trunk/kernel/kern/kernel_init.c

    r560 r561  
    621621
    622622                // compute target cluster for chdev[func,channel,direction]
    623                 uint32_t offset     = ext_chdev_gid % ( info->x_size * (info->y_max) ); // [FIXME]
    624                 uint32_t cx         = offset / (info->y_max); // [FIXME]
    625                 uint32_t cy         = offset % (info->y_max); // [FIXME]
    626                 uint32_t target_cxy = (cx<<info->y_width) + cy;
    627 
     623                uint32_t offset;
     624                uint32_t cx;
     625                uint32_t cy;
     626                uint32_t target_cxy;
     627                while (1) {
     628                    offset     = ext_chdev_gid % ( info->x_size * (info->y_size) );
     629                    cx         = offset / (info->y_size);
     630                    cy         = offset % (info->y_size);
     631                    target_cxy = (cx<<info->y_width) + cy;
     632                    // ext_chdev_gid that results in empty target clusters are skipped
     633                    if ( cluster_info_is_active( LOCAL_CLUSTER->cluster_info[cx][cy] ) == 0 ) {
     634                        ext_chdev_gid++;
     635                    } else { // The ext_chdev_gid resulted in a full target cluster
     636                        break;
     637                    }
     638                }
    628639                // allocate and initialize a local chdev
    629640                // when local cluster matches target cluster
  • trunk/kernel/mm/vmm.c

    r530 r561  
    4545#include <kmem.h>
    4646#include <vmm.h>
     47#include <cluster_info.h>
    4748
    4849//////////////////////////////////////////////////////////////////////////////////
     
    13841385    if( flags & VSEG_DISTRIB )    // distributed => cxy depends on vpn LSB
    13851386    {
    1386         uint32_t x_max   = LOCAL_CLUSTER->x_max; // [FIXME]
    1387         uint32_t y_max   = LOCAL_CLUSTER->y_max; // [FIXME]
     1387        uint32_t x_size  = LOCAL_CLUSTER->x_size;
     1388        uint32_t y_size  = LOCAL_CLUSTER->y_size;
    13881389        uint32_t y_width = LOCAL_CLUSTER->y_width;
    1389         uint32_t index   = vpn & ((x_max * y_max) - 1); // [FIXME]
    1390         uint32_t x       = index / y_max; // [FIXME]
    1391         uint32_t y       = index % y_max; // [FIXME]
    1392         page_cxy         = (x<<y_width) + y;
     1390        uint32_t index   = vpn & ((x_size * y_size) - 1);
     1391        uint32_t x       = index / y_size;
     1392        uint32_t y       = index % y_size;
     1393
     1394        // If the cluster selected from VPN's LSBs is empty, then we select one randomly
     1395        // cluster_random_select() ensures that its randomly selected cluster is not empty
     1396        if ( cluster_info_is_active( LOCAL_CLUSTER->cluster_info[x][y] ) == 0 ) {
     1397            cxy_t cxy = cluster_random_select();
     1398            x = ( ( cxy >> y_width ) & 0xF);
     1399            y = ( cxy & 0xF );
     1400        }
     1401        page_cxy = ( x << y_width ) + y;
    13931402    }
    13941403    else                          // other cases => cxy specified in vseg
    13951404    {
    1396         page_cxy         = vseg->cxy;
     1405        page_cxy = vseg->cxy;
    13971406    }
    13981407
Note: See TracChangeset for help on using the changeset viewer.