Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (4 years ago)
Author:
alain
Message:

1/ Fix a bug in the Multithreaded "sort" applicationr:
The pthread_create() arguments must be declared as global variables.
2/ The exit syscall can be called by any thread of a process..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/cluster.c

    r438 r440  
    153153#endif
    154154
    155     // initialises RPC fifo
    156         local_fifo_init( &cluster->rpc_fifo );
    157     cluster->rpc_threads = 0;
     155    // initialises RPC FIFOs
     156        for( lid = 0 ; lid < cluster->cores_nr; lid++ )
     157    {
     158            local_fifo_init( &cluster->rpc_fifo[lid] );
     159        cluster->rpc_threads[lid] = 0;
     160    }
    158161
    159162#if( DEBUG_CLUSTER_INIT & 1 )
     
    221224lid_t cluster_select_local_core()
    222225{
    223     uint32_t min = 100;
    224     lid_t    sel = 0;
    225     lid_t    lid;
     226    uint32_t      min = 1000;
     227    lid_t         sel = 0;
     228    uint32_t      nthreads;
     229    lid_t         lid;
     230    scheduler_t * sched;
    226231
    227232    cluster_t * cluster = LOCAL_CLUSTER;
     
    229234    for( lid = 0 ; lid < cluster->cores_nr ; lid++ )
    230235    {
    231         if( cluster->core_tbl[lid].usage < min )
     236        sched    = &cluster->core_tbl[lid].scheduler;
     237        nthreads = sched->u_threads_nr + sched->k_threads_nr;
     238
     239        if( nthreads < min )
    232240        {
    233             min = cluster->core_tbl[lid].usage;
     241            min = nthreads;
    234242            sel = lid;
    235243        }
     
    323331    bool_t      found;
    324332
     333#if DEBUG_CLUSTER_PID_ALLOC
     334uint32_t cycle = (uint32_t)hal_get_cycles();
     335if( DEBUG_CLUSTER_PID_ALLOC < cycle )
     336printk("\n[DBG] %s : thread %x enters in cluster %x / cycle %d\n",
     337__FUNCTION__ , CURRENT_THREAD , local_cxy , cycle );
     338#endif
     339
    325340    pmgr_t    * pm         = &LOCAL_CLUSTER->pmgr;
    326341
     
    361376    }
    362377
     378#if DEBUG_CLUSTER_PID_ALLOC
     379cycle = (uint32_t)hal_get_cycles();
     380if( DEBUG_CLUSTER_PID_ALLOC < cycle )
     381printk("\n[DBG] %s : thread %x exit in cluster %x / pid %x / cycle %d\n",
     382__FUNCTION__ , CURRENT_THREAD , local_cxy , *pid , cycle );
     383#endif
     384
    363385} // end cluster_pid_alloc()
    364386
     
    366388void cluster_pid_release( pid_t pid )
    367389{
     390
     391#if DEBUG_CLUSTER_PID_RELEASE
     392uint32_t cycle = (uint32_t)hal_get_cycles();
     393if( DEBUG_CLUSTER_PID_RELEASE < cycle )
     394printk("\n[DBG] %s : thread %x enters in cluster %x / pid %x / cycle %d\n",
     395__FUNCTION__ , CURRENT_THREAD , local_cxy , pid , cycle );
     396#endif
     397
    368398    cxy_t  owner_cxy  = CXY_FROM_PID( pid );
    369399    lpid_t lpid       = LPID_FROM_PID( pid );
     
    371401    pmgr_t  * pm = &LOCAL_CLUSTER->pmgr;
    372402
    373     // check pid argument
    374     assert( (lpid < CONFIG_MAX_PROCESS_PER_CLUSTER) && (owner_cxy == local_cxy) ,
    375     __FUNCTION__ , "illegal PID" );
     403    // check lpid
     404    assert( (lpid < CONFIG_MAX_PROCESS_PER_CLUSTER), __FUNCTION__ ,
     405    "illegal LPID = %d" , lpid );
     406
     407    // check owner cluster
     408    assert( (owner_cxy == local_cxy) , __FUNCTION__ ,
     409    "local_cluster %x !=  owner_cluster %x" , local_cxy , owner_cxy );
    376410
    377411    // get the process manager lock
     
    384418    // release the processs_manager lock
    385419    spinlock_unlock( &pm->pref_lock );
     420
     421#if DEBUG_CLUSTER_PID_RELEASE
     422cycle = (uint32_t)hal_get_cycles();
     423if( DEBUG_CLUSTER_PID_RELEASE < cycle )
     424printk("\n[DBG] %s : thread %x exit in cluster %x / cycle %d\n",
     425__FUNCTION__ , CURRENT_THREAD , local_cxy , cycle );
     426#endif
    386427
    387428} // end cluster_pid_release()
Note: See TracChangeset for help on using the changeset viewer.