source: trunk/kernel/kern/scheduler.c @ 592

Last change on this file since 592 was 592, checked in by alain, 5 years ago

Simplify the sched_handle°signals() function:
The rwlock protecting the process th_tbl[]
is no more used when handling a THREAD_DELETE request.

File size: 25.4 KB
Line 
1/*
2 * scheduler.c - Core scheduler implementation.
3 *
4 * Author    Alain Greiner (2016,2017,2018)
5 *
6 * Copyright (c)  UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH. is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH. is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#include <kernel_config.h>
25#include <hal_kernel_types.h>
26#include <hal_switch.h>
27#include <hal_irqmask.h>
28#include <hal_context.h>
29#include <printk.h>
30#include <list.h>
31#include <core.h>
32#include <thread.h>
33#include <chdev.h>
34#include <scheduler.h>
35
36
37///////////////////////////////////////////////////////////////////////////////////////////
38//         global variables
39///////////////////////////////////////////////////////////////////////////////////////////
40
41extern chdev_directory_t    chdev_dir;          // allocated in kernel_init.c
42extern process_t            process_zero;       // allocated in kernel_init.c
43
44///////////////////////////////////////////////////////////////////////////////////////////
45//         private functions
46///////////////////////////////////////////////////////////////////////////////////////////
47
48
49////////////////////////////////////////////////////////////////////////////////////////////
50// This static function does NOT modify the scheduler state.
51// It just select a thread in the list of attached threads, implementing the following
52// three steps policy:
53// 1) It scan the list of kernel threads, from the next thread after the last executed one,
54//    and returns the first runnable found : not IDLE, not blocked, client queue not empty.
55//    It can be the current thread.
56// 2) If no kernel thread found, it scan the list of user thread, from the next thread after
57//    the last executed one, and returns the first runable found : not blocked.
58//    It can be the current thread.
59// 3) If no runable thread found, it returns the idle thread.
60////////////////////////////////////////////////////////////////////////////////////////////
61// @ sched   : local pointer on scheduler.
62// @ returns pointer on selected thread descriptor
63////////////////////////////////////////////////////////////////////////////////////////////
64thread_t * sched_select( scheduler_t * sched )
65{
66    thread_t     * thread;
67    list_entry_t * current;
68    list_entry_t * last;
69    list_entry_t * root;
70    bool_t         done;
71    uint32_t       count;
72
73    // first : scan the kernel threads list if not empty
74    if( list_is_empty( &sched->k_root ) == false )
75    {
76        root    = &sched->k_root;
77        last    = sched->k_last;
78        done    = false;
79        count   = 0;
80        current = last;
81
82        while( done == false )
83        {
84
85// check kernel threads list
86assert( (count < sched->k_threads_nr), "bad kernel threads list" );
87
88            // get next entry in kernel list
89            current = current->next;
90
91            // check exit condition
92            if( current == last ) done = true;
93
94            // skip the root that does not contain a thread
95            if( current == root ) continue;
96            else                  count++;
97
98            // get thread pointer for this entry
99            thread = LIST_ELEMENT( current , thread_t , sched_list );
100
101            // select kernel thread if non blocked and non THREAD_IDLE
102            if( (thread->blocked == 0)  && (thread->type != THREAD_IDLE) ) return thread;
103
104        } // end loop on kernel threads
105    } // end kernel threads
106
107    // second : scan the user threads list if not empty
108    if( list_is_empty( &sched->u_root ) == false )
109    {
110        root    = &sched->u_root;
111        last    = sched->u_last;
112        done    = false;
113        count   = 0;
114        current = last;
115
116        while( done == false )
117        {
118
119// check user threads list
120assert( (count < sched->u_threads_nr), "bad user threads list" );
121
122            // get next entry in user list
123            current = current->next;
124
125            // check exit condition
126            if( current == last ) done = true;
127
128            // skip the root that does not contain a thread
129            if( current == root ) continue;
130            else                  count++;
131
132            // get thread pointer for this entry
133            thread = LIST_ELEMENT( current , thread_t , sched_list );
134
135            // select thread if non blocked
136            if( thread->blocked == 0 )  return thread;
137
138        } // end loop on user threads
139    } // end user threads
140
141    // third : return idle thread if no other runnable thread
142    return sched->idle;
143
144}  // end sched_select()
145
146////////////////////////////////////////////////////////////////////////////////////////////
147// This static function is the only function that can actually delete a thread,
148// and the associated process descriptor, if required.
149// It is private, because it is called by the sched_yield() public function.
150// It scan all threads attached to a given scheduler, and executes the relevant
151// actions for two types of pending requests:
152//
153// - REQ_ACK : it checks that target thread is blocked, decrements the response counter
154//   to acknowledge the client thread, and reset the pending request.
155// - REQ_DELETE : it removes the target thread from the process th_tbl[], remove it
156//   from the scheduler list, and release the memory allocated to thread descriptor.
157//   For an user thread, it destroys the process descriptor it the target thread is
158//   the last thread in the local process descriptor.
159//
160// Implementation note:
161// We use a while to scan the threads in scheduler lists, because some threads can
162// be destroyed, and we want not use a LIST_FOREACH()
163////////////////////////////////////////////////////////////////////////////////////////////
164// @ core    : local pointer on the core descriptor.
165////////////////////////////////////////////////////////////////////////////////////////////
166static void sched_handle_signals( core_t * core )
167{
168
169    list_entry_t * iter;
170    list_entry_t * root;
171    thread_t     * thread;
172    process_t    * process;
173    scheduler_t  * sched;
174    uint32_t       threads_nr;   // number of threads in scheduler list
175    ltid_t         ltid;         // thread local index
176    uint32_t       count;        // number of threads in local process
177
178    // get pointer on scheduler
179    sched = &core->scheduler;
180
181    // take the lock protecting sheduler state
182    busylock_acquire( &sched->lock );
183
184    ////// scan user threads to handle both ACK and DELETE requests
185    root = &sched->u_root;
186    iter = root->next;
187    while( iter != root )
188    {
189        // get pointer on thread
190        thread = LIST_ELEMENT( iter , thread_t , sched_list );
191
192        // increment iterator
193        iter = iter->next;
194
195        // handle REQ_ACK
196        if( thread->flags & THREAD_FLAG_REQ_ACK )
197        {
198
199// check thread blocked
200assert( (thread->blocked & THREAD_BLOCKED_GLOBAL) , "thread not blocked" );
201 
202            // decrement response counter
203            hal_atomic_add( thread->ack_rsp_count , -1 );
204
205            // reset REQ_ACK in thread descriptor
206            thread_reset_req_ack( thread );
207        }
208
209        // handle REQ_DELETE only if target thread != calling thread
210        if( (thread->flags & THREAD_FLAG_REQ_DELETE) && (thread != CURRENT_THREAD) )
211        {
212            // get thread process descriptor
213            process = thread->process;
214
215            // get thread ltid
216            ltid = LTID_FROM_TRDID( thread->trdid);
217
218            // update scheduler state
219            threads_nr = sched->u_threads_nr;
220            sched->u_threads_nr = threads_nr - 1;
221            list_unlink( &thread->sched_list );
222            if( sched->u_last == &thread->sched_list )
223            {
224                if( threads_nr == 1 ) 
225                {
226                    sched->u_last = NULL;
227                }
228                else if( sched->u_root.next == &thread->sched_list )
229                {
230                    sched->u_last = sched->u_root.pred;
231                }
232                else
233                {
234                    sched->u_last = sched->u_root.next;
235                }
236            }
237
238// check th_nr value
239assert( (process->th_nr > 0) , "process th_nr cannot be 0\n" );
240
241            // remove thread from process th_tbl[]
242            process->th_tbl[ltid] = NULL;
243            hal_atomic_add( &process->th_nr , - 1 );
244 
245            // release memory allocated for thread descriptor
246            thread_destroy( thread );
247
248#if DEBUG_SCHED_HANDLE_SIGNALS
249uint32_t cycle = (uint32_t)hal_get_cycles();
250if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
251printk("\n[DBG] %s : thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
252__FUNCTION__ , process->pid , thread->trdid , local_cxy , thread->core->lid , cycle );
253#endif
254            // destroy process descriptor if last thread
255            if( count == 1 ) 
256            {
257                // delete process   
258                process_destroy( process );
259
260#if DEBUG_SCHED_HANDLE_SIGNALS
261cycle = (uint32_t)hal_get_cycles();
262if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
263printk("\n[DBG] %s : process %x in cluster %x deleted / cycle %d\n",
264__FUNCTION__ , process->pid , local_cxy , cycle );
265#endif
266            }
267        }
268    }  // end user threads
269
270    ////// scan kernel threads for DELETE only
271    root = &sched->k_root;
272    iter = root->next;
273    while( iter != root )
274    {
275        // get pointer on thread
276        thread = LIST_ELEMENT( iter , thread_t , sched_list );
277
278        // increment iterator
279        iter = iter->next;
280
281        // handle REQ_DELETE only if target thread != calling thread
282        if( (thread->flags & THREAD_FLAG_REQ_DELETE) && (thread != CURRENT_THREAD) )
283        {
284
285// check process descriptor is local kernel process
286assert( ( thread->process == &process_zero ) , "illegal process descriptor\n");
287
288            // get thread ltid
289            ltid = LTID_FROM_TRDID( thread->trdid);
290
291            // update scheduler state
292            threads_nr = sched->k_threads_nr;
293            sched->k_threads_nr = threads_nr - 1;
294            list_unlink( &thread->sched_list );
295            if( sched->k_last == &thread->sched_list )
296            {
297                if( threads_nr == 1 ) 
298                {
299                    sched->k_last = NULL;
300                }
301                else if( sched->k_root.next == &thread->sched_list )
302                {
303                    sched->k_last = sched->k_root.pred;
304                }
305                else
306                {
307                    sched->k_last = sched->k_root.next;
308                }
309            }
310
311            // get number of threads in local kernel process
312            count = process_zero.th_nr;
313
314// check th_nr value
315assert( (process_zero.th_nr > 0) , "kernel process th_nr cannot be 0\n" );
316
317            // remove thread from process th_tbl[]
318            process_zero.th_tbl[ltid] = NULL;
319            hal_atomic_add( &process_zero.th_nr , - 1 );
320 
321            // delete thread descriptor
322            thread_destroy( thread );
323
324#if DEBUG_SCHED_HANDLE_SIGNALS
325uint32_t cycle = (uint32_t)hal_get_cycles();
326if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
327printk("\n[DBG] %s : thread[%x,%x] on core[%x,%d] deleted / cycle %d\n",
328__FUNCTION__ , process_zero.pid , thread->trdid , local_cxy , thread->core->lid , cycle );
329#endif
330        }
331    }
332
333    // release the lock protecting sheduler state
334    busylock_release( &sched->lock );
335
336} // end sched_handle_signals()
337
338////////////////////////////////////////////////////////////////////////////////////////////
339// This static function is called by the sched_yield function when the RFC_FIFO
340// associated to the core is not empty.
341// It search an idle RPC thread for this core, and unblock it if found.
342// It creates a new RPC thread if no idle RPC thread is found.
343////////////////////////////////////////////////////////////////////////////////////////////
344// @ sched   : local pointer on scheduler.
345////////////////////////////////////////////////////////////////////////////////////////////
346static void sched_rpc_activate( scheduler_t * sched )
347{
348    error_t         error;
349    thread_t      * thread; 
350    list_entry_t  * iter;
351    lid_t           lid = CURRENT_THREAD->core->lid;
352    bool_t          found = false;
353
354    // search one IDLE RPC thread associated to the selected core   
355    LIST_FOREACH( &sched->k_root , iter )
356    {
357        thread = LIST_ELEMENT( iter , thread_t , sched_list );
358
359        if( (thread->type == THREAD_RPC) && 
360            (thread->blocked == THREAD_BLOCKED_IDLE ) ) 
361        {
362            found = true;
363            break;
364        }
365    }
366
367    if( found == false )     // create new RPC thread     
368    {
369        error = thread_kernel_create( &thread,
370                                      THREAD_RPC, 
371                                              &rpc_thread_func, 
372                                      NULL,
373                                          lid );
374        // check memory
375        if ( error )
376        {
377            printk("\n[ERROR] in %s : no memory to create a RPC thread in cluster %x\n",
378            __FUNCTION__, local_cxy );
379        }
380        else
381        {
382            // unblock created RPC thread
383            thread->blocked = 0;
384
385            // update RPC threads counter 
386            hal_atomic_add( &LOCAL_CLUSTER->rpc_threads[lid] , 1 );
387
388#if DEBUG_SCHED_RPC_ACTIVATE
389uint32_t cycle = (uint32_t)hal_get_cycles();
390if( DEBUG_SCHED_RPC_ACTIVATE < cycle ) 
391printk("\n[DBG] %s : new RPC thread %x created for core[%x,%d] / total %d / cycle %d\n",
392__FUNCTION__, thread->trdid, local_cxy, lid, LOCAL_CLUSTER->rpc_threads[lid], cycle );
393#endif
394        }
395    }
396    else                 // RPC thread found => unblock it
397    {
398        // unblock found RPC thread
399        thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_IDLE );
400
401#if DEBUG_SCHED_RPC_ACTIVATE
402uint32_t cycle = (uint32_t)hal_get_cycles();
403if( DEBUG_SCHED_RPC_ACTIVATE < cycle ) 
404printk("\n[DBG] %s : idle RPC thread %x unblocked for core[%x,%d] / cycle %d\n",
405__FUNCTION__, thread->trdid, local_cxy, lid, cycle );
406#endif
407
408    }
409
410} // end sched_rpc_activate()
411
412
413
414///////////////////////////////////////////////////////////////////////////////////////////
415//         public functions
416///////////////////////////////////////////////////////////////////////////////////////////
417
418////////////////////////////////
419void sched_init( core_t * core )
420{
421    scheduler_t * sched = &core->scheduler;
422
423    sched->u_threads_nr   = 0;
424    sched->k_threads_nr   = 0;
425
426    sched->current        = CURRENT_THREAD;
427    sched->idle           = NULL;               // initialized in kernel_init()
428    sched->u_last         = NULL;               // initialized in sched_register_thread()
429    sched->k_last         = NULL;               // initialized in sched_register_thread()
430
431    // initialise threads lists
432    list_root_init( &sched->u_root );
433    list_root_init( &sched->k_root );
434
435    // init lock
436    busylock_init( &sched->lock , LOCK_SCHED_STATE );
437
438    sched->req_ack_pending = false;             // no pending request
439    sched->trace           = false;             // context switches trace desactivated
440
441}  // end sched_init()
442
443////////////////////////////////////////////
444void sched_register_thread( core_t   * core,
445                            thread_t * thread )
446{
447    scheduler_t * sched = &core->scheduler;
448    thread_type_t type  = thread->type;
449
450    // take lock protecting sheduler state
451    busylock_acquire( &sched->lock );
452
453    if( type == THREAD_USER )
454    {
455        list_add_last( &sched->u_root , &thread->sched_list );
456        sched->u_threads_nr++;
457        if( sched->u_last == NULL ) sched->u_last = &thread->sched_list;
458    }
459    else // kernel thread
460    {
461        list_add_last( &sched->k_root , &thread->sched_list );
462        sched->k_threads_nr++;
463        if( sched->k_last == NULL ) sched->k_last = &thread->sched_list; 
464    }
465
466    // release lock
467    busylock_release( &sched->lock );
468
469}  // end sched_register_thread()
470
471//////////////////////////////////////
472void sched_yield( const char * cause )
473{
474    thread_t      * next;
475    thread_t      * current = CURRENT_THREAD;
476    core_t        * core    = current->core;
477    lid_t           lid     = core->lid;
478    scheduler_t   * sched   = &core->scheduler;
479    remote_fifo_t * fifo    = &LOCAL_CLUSTER->rpc_fifo[lid]; 
480 
481#if (DEBUG_SCHED_YIELD & 0x1)
482if( sched->trace ) sched_display( lid );
483#endif
484
485// This assert should never be false, as this check must be
486// done before by any function that can possibly deschedule...
487assert( (current->busylocks == 0),
488"unexpected descheduling of thread holding %d busylocks = %d\n", current->busylocks ); 
489
490    // activate or create an RPC thread if RPC_FIFO non empty
491    if( remote_fifo_is_empty( fifo ) == false )  sched_rpc_activate( sched );
492
493    // disable IRQs / save SR in current thread descriptor
494    hal_disable_irq( &current->save_sr );
495
496    // take lock protecting sheduler state
497    busylock_acquire( &sched->lock );
498   
499    // select next thread
500    next = sched_select( sched );
501
502// check next thread kernel_stack overflow
503assert( (next->signature == THREAD_SIGNATURE),
504"kernel stack overflow for thread %x on core[%x,%d] \n", next, local_cxy, lid );
505
506// check next thread attached to same core as the calling thread
507assert( (next->core == current->core),
508"next core %x != current core %x\n", next->core, current->core );
509
510// check next thread not blocked when type != IDLE
511assert( ((next->blocked == 0) || (next->type == THREAD_IDLE)) ,
512"next thread %x (%s) is blocked on core[%x,%d]\n", 
513next->trdid , thread_type_str(next->type) , local_cxy , lid );
514
515    // switch contexts and update scheduler state if next != current
516        if( next != current )
517    {
518        // update scheduler
519        sched->current = next;
520        if( next->type == THREAD_USER ) sched->u_last = &next->sched_list;
521        else                            sched->k_last = &next->sched_list;
522
523        // handle FPU ownership
524            if( next->type == THREAD_USER )
525        {
526                if( next == current->core->fpu_owner )  hal_fpu_enable();
527                else                                    hal_fpu_disable();
528        }
529
530        // release lock protecting scheduler state
531        busylock_release( &sched->lock );
532
533#if DEBUG_SCHED_YIELD
534if( sched->trace )
535printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
536"      thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n",
537__FUNCTION__, local_cxy, lid, cause, 
538current, thread_type_str(current->type), current->process->pid, current->trdid,next ,
539thread_type_str(next->type) , next->process->pid , next->trdid , (uint32_t)hal_get_cycles() );
540#endif
541
542        // switch CPU from current thread context to new thread context
543        hal_do_cpu_switch( current->cpu_context, next->cpu_context );
544    }
545    else
546    {
547        // release lock protecting scheduler state
548        busylock_release( &sched->lock );
549
550#if (DEBUG_SCHED_YIELD & 1)
551if( sched->trace )
552printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
553"      thread %x (%s) (%x,%x) continue / cycle %d\n",
554__FUNCTION__, local_cxy, lid, cause, current, thread_type_str(current->type),
555current->process->pid, current->trdid, (uint32_t)hal_get_cycles() );
556#endif
557
558    }
559
560    // handle pending requests for all threads executing on this core.
561    sched_handle_signals( core );
562
563    // exit critical section / restore SR from current thread descriptor
564    hal_restore_irq( CURRENT_THREAD->save_sr );
565
566}  // end sched_yield()
567
568
569///////////////////////////////
570void sched_display( lid_t lid )
571{
572    list_entry_t * iter;
573    thread_t     * thread;
574
575// check lid
576assert( (lid < LOCAL_CLUSTER->cores_nr), 
577"illegal core index %d\n", lid);
578
579    core_t       * core    = &LOCAL_CLUSTER->core_tbl[lid];
580    scheduler_t  * sched   = &core->scheduler;
581   
582    // get pointers on TXT0 chdev
583    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
584    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
585    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
586
587    // get extended pointer on remote TXT0 lock
588    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
589
590    // get TXT0 lock
591    remote_busylock_acquire( lock_xp );
592
593    nolock_printk("\n***** threads on core[%x,%d] / current %x / rpc_threads %d / cycle %d\n",
594    local_cxy , core->lid, sched->current, LOCAL_CLUSTER->rpc_threads[lid],
595    (uint32_t)hal_get_cycles() );
596
597    // display kernel threads
598    LIST_FOREACH( &sched->k_root , iter )
599    {
600        thread = LIST_ELEMENT( iter , thread_t , sched_list );
601        if (thread->type == THREAD_DEV) 
602        {
603            nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X / %s\n",
604            thread_type_str( thread->type ), thread->process->pid, thread->trdid,
605            thread, thread->blocked, thread->flags, thread->chdev->name );
606        }
607        else
608        {
609            nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X\n",
610            thread_type_str( thread->type ), thread->process->pid, thread->trdid,
611            thread, thread->blocked, thread->flags );
612        }
613    }
614
615    // display user threads
616    LIST_FOREACH( &sched->u_root , iter )
617    {
618        thread = LIST_ELEMENT( iter , thread_t , sched_list );
619        nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X\n",
620        thread_type_str( thread->type ), thread->process->pid, thread->trdid,
621        thread, thread->blocked, thread->flags );
622    }
623
624    // release TXT0 lock
625    remote_busylock_release( lock_xp );
626
627}  // end sched_display()
628
629/////////////////////////////////////
630void sched_remote_display( cxy_t cxy,
631                           lid_t lid )
632{
633    thread_t     * thread;
634
635// check cxy
636assert( (cluster_is_undefined( cxy ) == false),
637"illegal cluster %x\n", cxy );
638
639assert( (lid < hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) ) ),
640"illegal core index %d\n", lid );
641
642    // get local pointer on target scheduler
643    core_t      * core  = &LOCAL_CLUSTER->core_tbl[lid];
644    scheduler_t * sched = &core->scheduler;
645
646    // get local pointer on current thread in target scheduler
647    thread_t * current = hal_remote_lpt( XPTR( cxy, &sched->current ) );
648
649    // get local pointer on the first kernel and user threads list_entry
650    list_entry_t * k_entry = hal_remote_lpt( XPTR( cxy , &sched->k_root.next ) );
651    list_entry_t * u_entry = hal_remote_lpt( XPTR( cxy , &sched->u_root.next ) );
652   
653    // get pointers on TXT0 chdev
654    xptr_t    txt0_xp  = chdev_dir.txt_tx[0];
655    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
656    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
657
658    // get extended pointer on remote TXT0 chdev lock
659    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
660
661    // get TXT0 lock
662    remote_busylock_acquire( lock_xp );
663
664    // get rpc_threads
665    uint32_t rpcs = hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->rpc_threads[lid] ) );
666 
667    // display header
668    nolock_printk("\n***** threads on core[%x,%d] / current %x / rpc_threads %d / cycle %d\n",
669    cxy , lid, current, rpcs, (uint32_t)hal_get_cycles() );
670
671    // display kernel threads
672    while( k_entry != &sched->k_root )
673    {
674        // get local pointer on kernel_thread
675        thread = LIST_ELEMENT( k_entry , thread_t , sched_list );
676
677        // get relevant thead info
678        thread_type_t type    = hal_remote_l32 ( XPTR( cxy , &thread->type ) );
679        trdid_t       trdid   = hal_remote_l32 ( XPTR( cxy , &thread->trdid ) );
680        uint32_t      blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) );
681        uint32_t      flags   = hal_remote_l32 ( XPTR( cxy , &thread->flags ) );
682        process_t *   process = hal_remote_lpt( XPTR( cxy , &thread->process ) );
683        pid_t         pid     = hal_remote_l32 ( XPTR( cxy , &process->pid ) );
684
685        // display thread info
686        if (type == THREAD_DEV) 
687        {
688            char      name[16];
689            chdev_t * chdev = hal_remote_lpt( XPTR( cxy , &thread->chdev ) );
690            hal_remote_strcpy( XPTR( local_cxy , name ), XPTR( cxy , &chdev->name ) );
691
692            nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X / %s\n",
693            thread_type_str( type ), pid, trdid, thread, blocked, flags, name );
694        }
695        else
696        {
697            nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X\n",
698            thread_type_str( type ), pid, trdid, thread, blocked, flags );
699        }
700
701        // get next remote kernel thread list_entry
702        k_entry = hal_remote_lpt( XPTR( cxy , &k_entry->next ) );
703    }
704
705    // display user threads
706    while( u_entry != &sched->u_root )
707    {
708        // get local pointer on user_thread
709        thread = LIST_ELEMENT( u_entry , thread_t , sched_list );
710
711        // get relevant thead info
712        thread_type_t type    = hal_remote_l32 ( XPTR( cxy , &thread->type ) );
713        trdid_t       trdid   = hal_remote_l32 ( XPTR( cxy , &thread->trdid ) );
714        uint32_t      blocked = hal_remote_l32 ( XPTR( cxy , &thread->blocked ) );
715        uint32_t      flags   = hal_remote_l32 ( XPTR( cxy , &thread->flags ) );
716        process_t *   process = hal_remote_lpt( XPTR( cxy , &thread->process ) );
717        pid_t         pid     = hal_remote_l32 ( XPTR( cxy , &process->pid ) );
718
719        nolock_printk(" - %s / pid %X / trdid %X / desc %X / block %X / flags %X\n",
720        thread_type_str( type ), pid, trdid, thread, blocked, flags );
721
722        // get next user thread list_entry
723        u_entry = hal_remote_lpt( XPTR( cxy , &u_entry->next ) );
724    }
725
726    // release TXT0 lock
727    remote_busylock_release( lock_xp );
728
729}  // end sched_remote_display()
730
731
Note: See TracBrowser for help on using the repository browser.