Ignore:
Timestamp:
Feb 12, 2019, 1:15:47 PM (6 years ago)
Author:
alain
Message:

1) Fix a bug in KSH : after the "load" command,

the [ksh] prompt is now printed after completion
of the loaded application.

2) Fix a bug in vmm_handle_cow() : the copy-on-write

use now a hal_remote_memcpy() to replicate the page content.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_barrier.c

    r581 r619  
    2424#include <hal_kernel_types.h>
    2525#include <hal_special.h>
     26#include <hal_uspace.h>
    2627#include <errno.h>
    2728#include <thread.h>
     
    4344
    4445//////////////////////////////////
    45 int sys_barrier( void     * vaddr,
     46int sys_barrier( intptr_t  vaddr,
    4647                 uint32_t   operation,
    47                  uint32_t   count )
     48                 uint32_t   count,
     49                 intptr_t   attr )   
    4850{
    49         error_t      error;
    50     vseg_t     * vseg;
    51  
    52     thread_t   * this    = CURRENT_THREAD;
    53     process_t  * process = this->process;
     51        error_t                 error;
     52    vseg_t                * vseg;
     53    pthread_barrierattr_t   k_attr;
     54
     55    thread_t  * this    = CURRENT_THREAD;
     56    process_t * process = this->process;
    5457
    5558#if DEBUG_SYS_BARRIER
     
    5861tm_start = hal_get_cycles();
    5962if( DEBUG_SYS_BARRIER < tm_start )
    60 printk("\n[DBG] %s : thread %x in process %x enter for %s / count %d / cycle %d\n",
    61 __FUNCTION__, this->trdid, process->pid, sys_barrier_op_str(operation), count,
     63printk("\n[%s] thread[%x,%x] enters for %s / count %d / cycle %d\n",
     64__FUNCTION__, process->pid, this->trdid, sys_barrier_op_str(operation), count,
    6265(uint32_t)tm_start );
    6366#endif
    6467
    6568    // check vaddr in user vspace
    66         error = vmm_get_vseg( process , (intptr_t)vaddr , &vseg );
    67 
     69        error = vmm_get_vseg( process , vaddr , &vseg );
    6870        if( error )
    6971    {
     
    7173#if DEBUG_SYSCALLS_ERROR
    7274printk("\n[ERROR] in %s : unmapped barrier %x / thread %x / process %x\n",
    73 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     75__FUNCTION__ , vaddr , this->trdid , process->pid );
    7476vmm_display( process , false );
    7577#endif
     
    8486            case BARRIER_INIT:
    8587        {
    86             error = remote_barrier_create( (intptr_t)vaddr , count );
    87    
     88            if( attr != 0 )   // QDT barrier required
     89            {
     90                error = vmm_get_vseg( process , attr , &vseg );
     91                if( error )
     92                {
     93
     94#if DEBUG_SYSCALLS_ERROR
     95printk("\n[ERROR] in %s : unmapped barrier attributes %x / thread %x / process %x\n",
     96__FUNCTION__ , attr , this->trdid , process->pid );
     97vmm_display( process , false );
     98#endif
     99                    this->errno = EINVAL;
     100                    return -1;
     101                }
     102 
     103                // copy barrier attributes into kernel space
     104                hal_copy_from_uspace( &k_attr , (void*)attr , sizeof(pthread_barrierattr_t) );
     105
     106                if ( count != k_attr.x_size * k_attr.y_size *k_attr.nthreads ) 
     107                {
     108
     109#if DEBUG_SYSCALLS_ERROR
     110printk("\n[ERROR] in %s : wrong arguments / count %d / x_size %d / y_size %d / nthreads %x\n",
     111__FUNCTION__, count, k_attr.x_size, k_attr.y_size, k_attr.nthreads );
     112#endif
     113                    this->errno = EINVAL;
     114                    return -1;
     115                }
     116 
     117
     118                // call relevant system function
     119                error = generic_barrier_create( vaddr , count , &k_attr );
     120            }
     121            else               // simple barrier required
     122            {
     123                error = generic_barrier_create( vaddr , count , NULL );
     124            }
     125
    88126                    if( error )
    89127            {
     
    91129#if DEBUG_SYSCALLS_ERROR
    92130printk("\n[ERROR] in %s : cannot create barrier %x / thread %x / process %x\n",
    93 __FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     131__FUNCTION__ , vaddr , this->trdid , process->pid );
    94132#endif
    95                 this->errno = error;
     133                this->errno = ENOMEM;
    96134                return -1;
    97135            }
     
    101139            case BARRIER_WAIT:
    102140        {
    103             xptr_t barrier_xp = remote_barrier_from_ident( (intptr_t)vaddr );
     141            xptr_t barrier_xp = generic_barrier_from_ident( vaddr );
    104142
    105143            if( barrier_xp == XPTR_NULL )     // user error
     
    115153            else                          // success
    116154            {
    117                 remote_barrier_wait( barrier_xp );
     155                generic_barrier_wait( barrier_xp );
    118156            }
    119157            break;
     
    122160            case BARRIER_DESTROY:
    123161        {
    124             xptr_t barrier_xp = remote_barrier_from_ident( (intptr_t)vaddr );
     162            xptr_t barrier_xp = generic_barrier_from_ident( vaddr );
    125163
    126164            if( barrier_xp == XPTR_NULL )     // user error
     
    136174            else                          // success
    137175            {
    138                 remote_barrier_destroy( barrier_xp );
     176                generic_barrier_destroy( barrier_xp );
    139177            }
    140178            break;
     
    149187tm_end = hal_get_cycles();
    150188if( DEBUG_SYS_BARRIER < tm_end )
    151 printk("\n[DBG] %s : thread %x in process %x exit for %s / cost %d / cycle %d\n",
    152 __FUNCTION__, this->trdid, process->pid, sys_barrier_op_str(operation),
     189printk("\n[%s] thread[%x,%x] exit for %s / cost %d / cycle %d\n",
     190__FUNCTION__, process->pid, this->trdid, sys_barrier_op_str(operation),
    153191(uint32_t)(tm_end - tm_start), (uint32_t)tm_end );
    154192#endif
Note: See TracChangeset for help on using the changeset viewer.