Changeset 23 for trunk/kernel/kern/cluster.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/cluster.c
r19 r23 4 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Mohamed Lamine Karaoui (2015) 6 * Alain Greiner (2016 )6 * Alain Greiner (2016,2017) 7 7 * 8 8 * Copyright (c) UPMC Sorbonne Universites … … 49 49 /////////////////////////////////////////////////////////////////////////////////////////// 50 50 51 process_t process_zero; // allocated in kernel_init.c file51 extern process_t process_zero; // allocated in kernel_init.c file 52 52 53 53 … … 121 121 122 122 // initialise local_list in process manager 123 spinlock_init( &cluster->pmgr.local_lock);124 list_root_init( &cluster->pmgr.local_root);123 remote_spinlock_init( XPTR( local_cxy , &cluster->pmgr.local_lock ) ); 124 xlist_root_init( XPTR( local_cxy , &cluster->pmgr.local_root ) ); 125 125 cluster->pmgr.local_nr = 0; 126 126 … … 162 162 { 163 163 cluster_t * cluster = LOCAL_CLUSTER; 164 hal_atomic_ inc( &cluster->cores_in_kernel);164 hal_atomic_add( &cluster->cores_in_kernel , 1 ); 165 165 } 166 166 … … 169 169 { 170 170 cluster_t * cluster = LOCAL_CLUSTER; 171 hal_atomic_ dec( &cluster->cores_in_kernel);171 hal_atomic_add( &cluster->cores_in_kernel , -1 ); 172 172 } 173 173 … … 199 199 xptr_t cluster_get_reference_process_from_pid( pid_t pid ) 200 200 { 201 xptr_t xp; // extended pointer onprocess descriptor201 xptr_t ref_xp; // extended pointer on reference process descriptor 202 202 203 203 cluster_t * cluster = LOCAL_CLUSTER; … … 208 208 209 209 // Check valid PID 210 if( lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER ) 211 { 212 printk("\n[PANIC] in %s : illegal PID\n", __FUNCTION__ ); 213 hal_core_sleep(); 214 } 210 if( lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER ) return XPTR_NULL; 215 211 216 212 if( local_cxy == owner_cxy ) // local cluster is owner cluster 217 213 { 218 xp = cluster->pmgr.pref_tbl[lpid];214 ref_xp = cluster->pmgr.pref_tbl[lpid]; 219 215 } 220 216 else // use a remote_lwd to access owner cluster 221 217 { 222 xp = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.pref_tbl[lpid] ) );223 } 224 225 return xp;218 ref_xp = (xptr_t)hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.pref_tbl[lpid] ) ); 219 } 220 221 return ref_xp; 226 222 } 227 223 … … 303 299 process_t * cluster_get_local_process_from_pid( pid_t pid ) 304 300 { 305 process_t * ret = NULL; 306 list_entry_t * root = &LOCAL_CLUSTER->pmgr.local_root; 307 list_entry_t * iter; 308 process_t * process; 309 310 LIST_FOREACH( root , iter ) 311 { 312 process = LIST_ELEMENT( iter , process_t , local_list ); 313 if( process->pid == pid ) 301 xptr_t process_xp; 302 process_t * process_ptr; 303 xptr_t root_xp; 304 xptr_t iter_xp; 305 bool_t found; 306 307 found = false; 308 root_xp = XPTR( local_cxy , &LOCAL_CLUSTER->pmgr.local_root ); 309 310 XLIST_FOREACH( root_xp , iter_xp ) 311 { 312 process_xp = XLIST_ELEMENT( iter_xp , process_t , local_list ); 313 process_ptr = (process_t *)GET_PTR( process_xp ); 314 if( process_ptr->pid == pid ) 314 315 { 315 ret = process;316 found = true; 316 317 break; 317 318 } 318 319 } 319 return ret; 320 321 if (found ) return process_ptr; 322 else return NULL; 320 323 321 324 } // end cluster_get_local_process_from_pid() … … 327 330 328 331 // get lock protecting the process manager local list 329 spinlock_lock( &pm->local_lock ); 330 331 list_add_first( &pm->local_root , &process->local_list ); 332 remote_spinlock_lock( XPTR( local_cxy , &pm->local_lock ) ); 333 334 xlist_add_first( XPTR( local_cxy , &pm->local_root ), 335 XPTR( local_cxy , &process->local_list ) ); 332 336 pm->local_nr++; 333 337 334 338 // release lock protecting the process manager local list 335 spinlock_unlock( &pm->local_lock);339 remote_spinlock_unlock( XPTR( local_cxy , &pm->local_lock ) ); 336 340 } 337 341 … … 342 346 343 347 // get lock protecting the process manager local list 344 spinlock_lock( &pm->local_lock);345 346 list_unlink( &process->local_list);348 remote_spinlock_lock( XPTR( local_cxy , &pm->local_lock ) ); 349 350 xlist_unlink( XPTR( local_cxy , &process->local_list ) ); 347 351 pm->local_nr--; 348 352 349 353 // release lock protecting the process manager local list 350 spinlock_unlock( &pm->local_lock);354 remote_spinlock_unlock( XPTR( local_cxy , &pm->local_lock ) ); 351 355 } 352 356
Note: See TracChangeset
for help on using the changeset viewer.