Changeset 289 for trunk


Ignore:
Timestamp:
Jul 27, 2017, 4:44:18 PM (7 years ago)
Author:
max@…
Message:

Style, in order to appease GCC5.

File:
1 edited

Legend:

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

    r101 r289  
    11/*
    22 * sys_thread_create.c - creates a new user thread
    3  * 
     3 *
    44 * Author     Alain Greiner (2016,2017)
    55 *
     
    5050        pthread_attr_t   k_attr;           // copy of pthread attributes in kernel space
    5151        thread_t       * parent;           // pointer on thread executing the pthread_create
    52     xptr_t           parent_xp;        // extended pointer on created thread
    53     thread_t       * child_ptr;        // pointer on created child thread
    54     xptr_t           child_xp;         // extended pointer on created thread
    55     trdid_t          trdid;            // created thread identifier
    56     process_t      * process;          // pointer on local process descriptor
    57     paddr_t          paddr;            // unused, required by vmm_v2p_translate()
    58     error_t          error;
     52        xptr_t           parent_xp;        // extended pointer on created thread
     53        thread_t       * child_ptr;        // pointer on created child thread
     54        xptr_t           child_xp;         // extended pointer on created thread
     55        trdid_t          trdid;            // created thread identifier
     56        process_t      * process;          // pointer on local process descriptor
     57        paddr_t          paddr;            // unused, required by vmm_v2p_translate()
     58        error_t          error;
    5959
    6060        uint32_t         tm_start;
     
    6363        tm_start = hal_get_cycles();
    6464
    65     // get parent thead pointer, extended pointer, and process pointer
     65        // get parent thead pointer, extended pointer, and process pointer
    6666        parent     = CURRENT_THREAD;
    67     parent_xp  = XPTR( local_cxy , parent );   
     67        parent_xp  = XPTR( local_cxy , parent );
    6868        process    = parent->process;
    6969
    70     // check user_attr in user space
    71     error = vmm_v2p_translate( false , user_attr , &paddr );
     70        // check user_attr in user space
     71        error = vmm_v2p_translate( false , user_attr , &paddr );
    7272
    7373        if( error )
     
    7575                printk("\n[ERROR] in %s : user_attr unmapped\n", __FUNCTION__ );
    7676                parent->errno = EINVAL;
    77         return -1;
     77                return -1;
    7878        }
    7979
    80     // check start_func in user space
    81     error = vmm_v2p_translate( false , start_func , &paddr );
     80        // check start_func in user space
     81        error = vmm_v2p_translate( false , start_func , &paddr );
    8282
    8383        if( error )
     
    8585                printk("\n[ERROR] in %s : start_func unmapped\n", __FUNCTION__ );
    8686                parent->errno = EINVAL;
    87         return -1;
     87                return -1;
    8888        }
    8989
    90     // check start_arg in user space
    91     if( start_arg != NULL ) error = vmm_v2p_translate( false , start_arg , &paddr );
     90        // check start_arg in user space
     91        if( start_arg != NULL ) error = vmm_v2p_translate( false , start_arg , &paddr );
    9292
    9393        if( error )
     
    9595                printk("\n[ERROR] in %s : start_arg unmapped\n", __FUNCTION__ );
    9696                parent->errno = EINVAL;
    97         return -1;
     97                return -1;
    9898        }
    9999
    100     // copy user_attr structure from user space to kernel space
     100        // copy user_attr structure from user space to kernel space
    101101        hal_copy_from_uspace( &k_attr , user_attr , sizeof(pthread_attr_t) );
    102102
    103     // check/set "cxy" attribute
    104         if( k_attr.attributes & PT_ATTR_CLUSTER_DEFINED ) 
    105     {
    106         if( cluster_is_undefined( k_attr.cxy ) )
    107         {
    108                     printk("\n[ERROR] in %s : illegal target cluster attribute = %x\n",
    109                    __FUNCTION__ , k_attr.cxy );
    110                     parent->errno = EINVAL;
    111             return -1;
    112         }
    113     }
    114     else
    115     {
    116         k_attr.cxy = dqdt_get_cluster_for_process();
    117     }
     103        // check/set "cxy" attribute
     104        if( k_attr.attributes & PT_ATTR_CLUSTER_DEFINED )
     105        {
     106                if( cluster_is_undefined( k_attr.cxy ) )
     107                {
     108                        printk("\n[ERROR] in %s : illegal target cluster attribute = %x\n",
     109                               __FUNCTION__ , k_attr.cxy );
     110                        parent->errno = EINVAL;
     111                        return -1;
     112                }
     113        }
     114        else
     115        {
     116                k_attr.cxy = dqdt_get_cluster_for_process();
     117        }
    118118
    119     // create the thread, using a RPC if required
    120     // this returns "error", "child", and "child_xp"
    121  
    122     if( k_attr.cxy == local_cxy )                         // target cluster is local
    123     {
     119        // create the thread, using a RPC if required
     120        // this returns "error", "child", and "child_xp"
    124121
    125         // create thread in local cluster
    126         error = thread_user_create( process->pid,
    127                                     start_func,
    128                                     start_arg,
    129                                     &k_attr,
    130                                     &child_ptr );
     122        if( k_attr.cxy == local_cxy )                         // target cluster is local
     123        {
     124                // create thread in local cluster
     125                error = thread_user_create( process->pid,
     126                                            start_func,
     127                                            start_arg,
     128                                            &k_attr,
     129                                            &child_ptr );
    131130
    132         child_xp = XPTR( local_cxy , child_ptr );
    133     }
    134     else                                                 // target cluster is remote
    135     {
    136         rpc_thread_user_create_client( k_attr.cxy,
    137                                        process->pid,
    138                                        start_func,
    139                                        start_arg,
    140                                        &k_attr,
    141                                        &child_xp,
    142                                        &error );
     131                child_xp = XPTR( local_cxy , child_ptr );
     132        }
     133        else                                                 // target cluster is remote
     134        {
     135                rpc_thread_user_create_client( k_attr.cxy,
     136                                               process->pid,
     137                                               start_func,
     138                                               start_arg,
     139                                               &k_attr,
     140                                               &child_xp,
     141                                               &error );
    143142
    144         child_ptr = (thread_t *)GET_PTR( child_xp );
    145     }
     143                child_ptr = (thread_t *)GET_PTR( child_xp );
     144        }
    146145
    147     // check successful thread creation
    148     if( error )
    149     {
     146        // check successful thread creation
     147        if( error )
     148        {
    150149                printk("\n[ERROR] in %s : cannot create thread\n", __FUNCTION__ );
    151         return ENOMEM;
    152     }
     150                return ENOMEM;
     151        }
    153152
    154     // returns trdid to user space
    155     trdid = hal_remote_lw( XPTR( k_attr.cxy , &child_ptr->trdid ) );   
     153        // returns trdid to user space
     154        trdid = hal_remote_lw( XPTR( k_attr.cxy , &child_ptr->trdid ) );
    156155        hal_copy_to_uspace( new_thread , &trdid , sizeof(pthread_t) );
    157    
    158     // register new-thread in parent-thread children list if required
    159     if( (k_attr.attributes & PT_ATTR_DETACH) == 0 )
    160         thread_child_parent_link( parent_xp , child_xp );
     156
     157        // register new-thread in parent-thread children list if required
     158        if( (k_attr.attributes & PT_ATTR_DETACH) == 0 )
     159            thread_child_parent_link( parent_xp , child_xp );
    161160
    162161        tm_end = hal_get_cycles();
    163162
    164163        thread_dmsg("\n[INFO] %s created thread %x for process %x in cluster %x\n"
    165                 "  start_cycle = %d / end_cycle = %d\n",
    166                    trdid , process->pid , k_attr.cxy , tm_start , tm_end );
     164                    "  start_cycle = %d / end_cycle = %d\n",
     165                       trdid , process->pid , k_attr.cxy , tm_start , tm_end );
    167166        return 0;
     167}
    168168
    169 }  // end sys_thread_create()
    170 
    171 
Note: See TracChangeset for help on using the changeset viewer.