Changeset 635 for trunk/kernel/libk/remote_sem.c
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_sem.c
r563 r635 2 2 * remote_sem.c - POSIX unnamed semaphore implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018 )4 * Author Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 86 86 uint32_t value ) 87 87 { 88 kmem_req_t req; 88 89 remote_sem_t * sem_ptr; 89 xptr_t sem_xp;90 90 91 91 // get pointer on local process descriptor … … 100 100 101 101 // allocate memory for new semaphore in reference cluster 102 if( ref_cxy == local_cxy ) // local cluster is the reference 103 { 104 kmem_req_t req; 105 req.type = KMEM_SEM; 106 req.flags = AF_ZERO; 107 sem_ptr = kmem_alloc( &req ); 108 sem_xp = XPTR( local_cxy , sem_ptr ); 102 req.type = KMEM_KCM; 103 req.order = bits_log2( sizeof(remote_sem_t) ); 104 req.flags = AF_ZERO | AF_KERNEL; 105 sem_ptr = kmem_remote_alloc( ref_cxy, &req ); 106 107 if( sem_ptr == NULL ) 108 { 109 printk("\n[ERROR] in %s : cannot create semaphore\n", __FUNCTION__ ); 110 return -1; 109 111 } 110 else // reference is remote111 {112 rpc_kcm_alloc_client( ref_cxy , KMEM_SEM , &sem_xp );113 sem_ptr = GET_PTR( sem_xp );114 }115 116 if( sem_xp == XPTR_NULL ) return 0xFFFFFFFF;117 112 118 113 // initialise semaphore … … 149 144 void remote_sem_destroy( xptr_t sem_xp ) 150 145 { 146 kmem_req_t req; 147 151 148 // get pointer on local process descriptor 152 149 process_t * process = CURRENT_THREAD->process; … … 179 176 180 177 // release memory allocated for semaphore descriptor 181 if( sem_cxy == local_cxy ) // reference is local 182 { 183 kmem_req_t req; 184 req.type = KMEM_SEM; 185 req.ptr = sem_ptr; 186 kmem_free( &req ); 187 } 188 else // reference is remote 189 { 190 rpc_kcm_free_client( sem_cxy , sem_ptr , KMEM_SEM ); 191 } 178 req.type = KMEM_KCM; 179 req.ptr = sem_ptr; 180 kmem_remote_free( sem_cxy , &req ); 192 181 193 182 } // end remote_sem_destroy()
Note: See TracChangeset
for help on using the changeset viewer.