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

    r23 r440  
    22 * sys_mutex.c - Access a POSIX mutex.
    33 *
    4  * Author    Alain Greiner (2016,2017)
     4 * Author    Alain Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3737               uint32_t   attr )
    3838{
    39         error_t    error;
    40     paddr_t    paddr;
     39        error_t     error;
     40    vseg_t    * vseg;
    4141
    42     thread_t * this = CURRENT_THREAD;
     42    thread_t  * this    = CURRENT_THREAD;
     43    process_t * process = this->process;
    4344
    4445    // check vaddr in user vspace
    45         error = vmm_v2p_translate( false , vaddr , &paddr );
     46        error = vmm_get_vseg( process , (intptr_t)vaddr , &vseg );
     47
    4648        if( error )
    4749    {
    48         printk("\n[ERROR] in %s : illegal virtual address = %x\n",
    49                __FUNCTION__ , (intptr_t)vaddr );
     50
     51#if DEBUG_SYSCALLS_ERROR
     52printk("\n[ERROR] in %s : mutex unmapped %x / thread %x / process %x\n",
     53__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     54vmm_display( process , false );
     55#endif
    5056        this->errno = error;
    5157        return -1;
     
    6066            if( attr != 0 )
    6167            {
    62                 printk("\n[ERROR] in %s : mutex attributes non supported yet\n",
    63                        __FUNCTION__ );
     68
     69#if DEBUG_SYSCALLS_ERROR
     70printk("\n[ERROR] in %s : mutex attribute non supported / thread %x / process %x\n",
     71__FUNCTION__ , this->trdid , process->pid );
     72#endif
    6473                this->errno = error;
    6574                return -1;
     
    7079            if( error )
    7180            {
    72                 printk("\n[ERROR] in %s : cannot create mutex\n",
    73                        __FUNCTION__ );
     81
     82#if DEBUG_SYSCALLS_ERROR
     83printk("\n[ERROR] in %s : cannot create mutex / thread %x / process %x\n",
     84__FUNCTION__ , this->trdid , process->pid );
     85#endif
    7486                this->errno = error;
    7587                return -1;
     
    8496            if( mutex_xp == XPTR_NULL )     // user error
    8597            {
    86                 printk("\n[ERROR] in %s : mutex %x not registered\n",
    87                        __FUNCTION__ , (intptr_t)vaddr );
     98
     99#if DEBUG_SYSCALLS_ERROR
     100printk("\n[ERROR] in %s : mutex %x not registered / thread %x / process %x\n",
     101__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     102#endif
    88103                this->errno = EINVAL;
    89104                return -1;
     
    102117            if( mutex_xp == XPTR_NULL )     // user error
    103118            {
    104                 printk("\n[ERROR] in %s : mutex %x not registered\n",
    105                        __FUNCTION__ , (intptr_t)vaddr );
     119
     120#if DEBUG_SYSCALLS_ERROR
     121printk("\n[ERROR] in %s : mutex %x not registered / thread %x / process %x\n",
     122__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     123#endif
    106124                this->errno = EINVAL;
    107125                return -1;
     
    120138            if( mutex_xp == XPTR_NULL )     // user error
    121139            {
    122                 printk("\n[ERROR] in %s : mutex %x not registered\n",
    123                        __FUNCTION__ , (intptr_t)vaddr );
     140
     141#if DEBUG_SYSCALLS_ERROR
     142printk("\n[ERROR] in %s : mutex %x not registered / thread %x / process %x\n",
     143__FUNCTION__ , (intptr_t)vaddr , this->trdid , process->pid );
     144#endif
    124145                this->errno = EINVAL;
    125146                return -1;
Note: See TracChangeset for help on using the changeset viewer.