Ignore:
Timestamp:
May 3, 2018, 5:51:22 PM (7 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/syscalls/sys_condvar.c

    r23 r440  
    22 * sys_condvar.c - Access a POSIX condvar.
    33 *
    4  * Author    Alain Greiner  (2016,2017)
     4 * Author    Alain Greiner  (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3030#include <syscalls.h>
    3131#include <remote_condvar.h>
     32#include <remote_mutex.h>
    3233
    3334////////////////////////////////////////
     
    3637                 void         * mutex )
    3738{
    38         error_t    error;
    39     paddr_t    paddr;
     39        error_t     error;
     40    vseg_t    * vseg;
    4041 
    41     thread_t * this = CURRENT_THREAD;
     42    thread_t  * this    = CURRENT_THREAD;
     43    process_t * process = this->process;
    4244
    4345    // check condvar in user vspace
    44         error = vmm_v2p_translate( false , condvar , &paddr );
     46        error = vmm_get_vseg( process , (intptr_t)condvar , &vseg );
     47
    4548        if( error )
    4649    {
    47         printk("\n[ERROR] in %s : illegal condvar virtual address = %x\n",
    48                __FUNCTION__ , (intptr_t)condvar );
     50
     51#if DEBUG_SYSCALLS_ERROR
     52printk("\n[ERROR] in %s : unmapped condvar %x / thread %x / process %x\n",
     53__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     54vmm_display( process , false );
     55#endif
    4956        this->errno = error;
    5057        return -1;
     
    6168                    if( error )
    6269            {
    63                 printk("\n[ERROR] in %s : cannot create condvar = %x\n",
    64                        __FUNCTION__ , (intptr_t)condvar );
     70
     71#if DEBUG_SYSCALLS_ERROR
     72printk("\n[ERROR] in %s : cannot create condvar %x / thread %x / process %x\n",
     73__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     74#endif
    6575                this->errno = error;
    6676                return -1;
     
    7282        {
    7383            // check mutex in user vspace
    74                 error = vmm_v2p_translate( false , mutex , &paddr );
     84                error = vmm_get_vseg( process , (intptr_t)mutex , &vseg );
    7585
    7686                if( error )
    7787            {
    78                 printk("\n[ERROR] in %s : illegal condvar virtual address = %x\n",
    79                        __FUNCTION__ , (intptr_t)condvar );
     88
     89#if DEBUG_SYSCALLS_ERROR
     90printk("\n[ERROR] in %s : unmapped mutex %x / thread %x / process %x\n",
     91__FUNCTION__ , (intptr_t)mutex , this->trdid , process->pid );
     92#endif
    8093                this->errno = error;
    8194                return -1;
     
    8699            if( condvar_xp == XPTR_NULL )     // user error
    87100            {
    88                 printk("\n[ERROR] in %s : condvar %x not registered\n",
    89                        __FUNCTION__ , (intptr_t)condvar );
     101
     102#if DEBUG_SYSCALLS_ERROR
     103printk("\n[ERROR] in %s : condvar %x not registered / thread %x / process %x\n",
     104__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     105#endif
    90106                this->errno = EINVAL;
    91107                return -1;
    92108            }
    93109   
    94             xptr_t mutex_xp = remote_condvar_from_ident( (intptr_t)condvar );
     110            xptr_t mutex_xp = remote_mutex_from_ident( (intptr_t)mutex );
     111
    95112            if( mutex_xp == XPTR_NULL )     // user error
    96113            {
    97                 printk("\n[ERROR] in %s : mutex %x not registered\n",
    98                        __FUNCTION__ , (intptr_t)condvar );
     114
     115#if DEBUG_SYSCALLS_ERROR
     116printk("\n[ERROR] in %s : mutex %x not registered / thread %x / process %x\n",
     117__FUNCTION__ , (intptr_t)mutex , this->trdid , process->pid );
     118#endif
    99119                this->errno = EINVAL;
    100120                return -1;
     
    112132            if( condvar_xp == XPTR_NULL )     // user error
    113133            {
    114                 printk("\n[ERROR] in %s : condvar %x not registered\n",
    115                        __FUNCTION__ , (intptr_t)condvar );
     134
     135#if DEBUG_SYSCALLS_ERROR
     136printk("\n[ERROR] in %s : condvar %x not registered / thread %x / process %x\n",
     137__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     138#endif
    116139                this->errno = EINVAL;
    117140                return -1;
     
    129152            if( condvar_xp == XPTR_NULL )     // user error
    130153            {
    131                 printk("\n[ERROR] in %s : condvar %x not registered\n",
    132                        __FUNCTION__ , (intptr_t)condvar );
     154
     155#if DEBUG_SYSCALLS_ERROR
     156printk("\n[ERROR] in %s : condvar %x not registered / thread %x / process %x\n",
     157__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     158#endif
    133159                this->errno = EINVAL;
    134160                return -1;
     
    146172            if( condvar_xp == XPTR_NULL )     // user error
    147173            {
    148                 printk("\n[ERROR] in %s : condvar %x not registered\n",
    149                        __FUNCTION__ , (intptr_t)condvar );
     174
     175#if DEBUG_SYSCALLS_ERROR
     176printk("\n[ERROR] in %s : condvar %x not registered / thread %x / process %x\n",
     177__FUNCTION__ , (intptr_t)condvar , this->trdid , process->pid );
     178#endif
    150179                this->errno = EINVAL;
    151180                return -1;
Note: See TracChangeset for help on using the changeset viewer.