Changes in / [3f12158:54d714e]


Ignore:
Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/CtxSwitch-i386.S

    r3f12158 r54d714e  
    9898        ret
    9999
     100.text
     101        .align 2
     102.globl  CtxGet
     103CtxGet:
     104        movl %esp,SP_OFFSET(%eax)
     105        movl %ebp,FP_OFFSET(%eax)
     106
     107        ret
     108
    100109// Local Variables: //
    101110// compile-command: "make install" //
  • src/libcfa/concurrency/CtxSwitch-x86_64.S

    r3f12158 r54d714e  
    1 //                               -*- Mode: Asm -*-
     1//                               -*- Mode: Asm -*- 
    22//
    33// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1818// Free Software  Foundation; either  version 2.1 of  the License, or  (at your
    1919// option) any later version.
    20 //
     20// 
    2121// This library is distributed in the  hope that it will be useful, but WITHOUT
    2222// ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
    2323// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
    2424// for more details.
    25 //
     25// 
    2626// You should  have received a  copy of the  GNU Lesser General  Public License
    2727// along  with this library.
    28 //
     28// 
    2929
    3030// This context switch routine depends on the fact that the stack of a new
     
    9393.globl  CtxInvokeStub
    9494CtxInvokeStub:
    95         movq %rbx, %rdi
     95        movq %rbx, %rdi 
    9696        jmp *%r12
     97
     98.text
     99        .align 2
     100.globl  CtxGet
     101CtxGet:
     102        movq %rsp,SP_OFFSET(%rdi)
     103        movq %rbp,FP_OFFSET(%rdi)
     104
     105        ret
    97106
    98107// Local Variables: //
  • src/libcfa/concurrency/invoke.h

    r3f12158 r54d714e  
    9999#ifndef _INVOKE_PRIVATE_H_
    100100#define _INVOKE_PRIVATE_H_
    101 
     101     
    102102      struct machine_context_t {
    103103            void *SP;
     
    109109      extern void CtxInvokeStub( void );
    110110      void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
    111 
    112       #if   defined( __x86_64__ )
    113       #define CtxGet( ctx ) __asm__ ( \
    114                   "movq %%rsp,%0\n"   \
    115                   "movq %%rbp,%1\n"   \
    116             : "=rm" (ctx.SP), "=rm" (ctx.FP) )
    117       #elif defined( __i386__ )
    118       #define CtxGet( ctx ) __asm__ ( \
    119                   "movl %%esp,%0\n"   \
    120                   "movl %%ebp,%1\n"   \
    121             : "=rm" (ctx.SP), "=rm" (ctx.FP) )
    122       #endif
     111      void CtxGet( void * this ) asm ("CtxGet");
    123112
    124113#endif //_INVOKE_PRIVATE_H_
  • src/libcfa/concurrency/kernel.c

    r3f12158 r54d714e  
    7272// Main thread construction
    7373struct current_stack_info_t {
    74         machine_context_t ctx;
     74        machine_context_t ctx; 
    7575        unsigned int size;              // size of stack
    7676        void *base;                             // base of stack
     
    8282
    8383void ?{}( current_stack_info_t * this ) {
    84         CtxGet( this->ctx );
     84        CtxGet( &this->ctx );
    8585        this->base = this->ctx.FP;
    8686        this->storage = this->ctx.SP;
     
    106106
    107107void ?{}( coroutine_desc * this, current_stack_info_t * info) {
    108         (&this->stack){ info };
     108        (&this->stack){ info }; 
    109109        this->name = "Main Thread";
    110110        this->errno_ = 0;
     
    184184
    185185void ^?{}(cluster * this) {
    186 
     186       
    187187}
    188188
     
    203203
    204204                thread_desc * readyThread = NULL;
    205                 for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
     205                for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ ) 
    206206                {
    207207                        readyThread = nextThread( this->cltr );
     
    229229}
    230230
    231 // runThread runs a thread by context switching
    232 // from the processor coroutine to the target thread
     231// runThread runs a thread by context switching 
     232// from the processor coroutine to the target thread 
    233233void runThread(processor * this, thread_desc * dst) {
    234234        coroutine_desc * proc_cor = get_coroutine(this->runner);
    235235        coroutine_desc * thrd_cor = get_coroutine(dst);
    236 
     236       
    237237        //Reset the terminating actions here
    238238        this->finish.action_code = No_Action;
     
    246246}
    247247
    248 // Once a thread has finished running, some of
     248// Once a thread has finished running, some of 
    249249// its final actions must be executed from the kernel
    250250void finishRunning(processor * this) {
     
    256256        }
    257257        else if( this->finish.action_code == Release_Schedule ) {
    258                 unlock( this->finish.lock );
     258                unlock( this->finish.lock );           
    259259                ScheduleThread( this->finish.thrd );
    260260        }
     
    291291        // SKULLDUGGERY: We want to create a context for the processor coroutine
    292292        // which is needed for the 2-step context switch. However, there is no reason
    293         // to waste the perfectly valid stack create by pthread.
     293        // to waste the perfectly valid stack create by pthread. 
    294294        current_stack_info_t info;
    295295        machine_context_t ctx;
     
    306306        LIB_DEBUG_PRINT_SAFE("Kernel : core %p created (%p, %p)\n", proc, proc->runner, &ctx);
    307307
    308         // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't
    309         // resume it to start it like it normally would, it will just context switch
    310         // back to here. Instead directly call the main since we already are on the
     308        // SKULLDUGGERY: Since the coroutine doesn't have its own stack, we can't 
     309        // resume it to start it like it normally would, it will just context switch 
     310        // back to here. Instead directly call the main since we already are on the 
    311311        // appropriate stack.
    312312        proc_cor_storage.__cor.state = Active;
     
    315315
    316316        // Main routine of the core returned, the core is now fully terminated
    317         LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner);
     317        LIB_DEBUG_PRINT_SAFE("Kernel : core %p main ended (%p)\n", proc, proc->runner); 
    318318
    319319        return NULL;
     
    322322void start(processor * this) {
    323323        LIB_DEBUG_PRINT_SAFE("Kernel : Starting core %p\n", this);
    324 
     324       
    325325        pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
    326326
    327         LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);
     327        LIB_DEBUG_PRINT_SAFE("Kernel : core %p started\n", this);       
    328328}
    329329
     
    334334
    335335        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    336 
     336       
    337337        lock( &systemProcessor->proc.cltr->lock );
    338338        append( &systemProcessor->proc.cltr->ready_queue, thrd );
     
    392392// Kernel boot procedures
    393393void kernel_startup(void) {
    394         LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");
     394        LIB_DEBUG_PRINT_SAFE("Kernel : Starting\n");   
    395395
    396396        // Start by initializing the main thread
    397         // SKULLDUGGERY: the mainThread steals the process main thread
     397        // SKULLDUGGERY: the mainThread steals the process main thread 
    398398        // which will then be scheduled by the systemProcessor normally
    399399        mainThread = (thread_desc *)&mainThread_storage;
     
    417417        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtx_storage };
    418418
    419         // Add the main thread to the ready queue
     419        // Add the main thread to the ready queue 
    420420        // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
    421421        ScheduleThread(mainThread);
     
    428428        // SKULLDUGGERY: Force a context switch to the system processor to set the main thread's context to the current UNIX
    429429        // context. Hence, the main thread does not begin through CtxInvokeThread, like all other threads. The trick here is that
    430         // mainThread is on the ready queue when this call is made.
     430        // mainThread is on the ready queue when this call is made. 
    431431        resume( systemProcessor->proc.runner );
    432432
     
    457457        ^(mainThread){};
    458458
    459         LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");
     459        LIB_DEBUG_PRINT_SAFE("Kernel : Shutdown complete\n");   
    460460}
    461461
     
    473473                kernel_abort_called = true;
    474474                unlock( &kernel_abort_lock );
    475         }
     475        } 
    476476        else {
    477477                unlock( &kernel_abort_lock );
    478 
     478               
    479479                sigset_t mask;
    480480                sigemptyset( &mask );
     
    482482                sigaddset( &mask, SIGUSR1 );                    // block SIGUSR1 signals
    483483                sigsuspend( &mask );                            // block the processor to prevent further damage during abort
    484                 _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it
     484                _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it             
    485485        }
    486486
     
    497497                len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine()->name, this_coroutine() );
    498498                __lib_debug_write( STDERR_FILENO, abort_text, len );
    499         }
     499        } 
    500500        else {
    501501                __lib_debug_write( STDERR_FILENO, ".\n", 2 );
     
    590590                }
    591591                head->next = NULL;
    592         }
     592        }       
    593593        return head;
    594594}
     
    609609                this->top = top->next;
    610610                top->next = NULL;
    611         }
     611        }       
    612612        return top;
    613613}
  • src/tests/Makefile.am

    r3f12158 r54d714e  
    2929
    3030# applies to both programs
    31 DEBUG_FLAGS =
    32 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@
    33 if !BUILD_DEBUG
    34 BUILD_FLAGS += -nodebug
    35 else
    36 if !BUILD_RELEASE
    37 BUILD_FLAGS += -debug
    38 else
    39 BUILD_FLAGS += ${BUILD_FLAGS}
    40 endif
    41 endif
    42 
     31EXTRA_FLAGS =
     32BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
    4333TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
    4434AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
  • src/tests/Makefile.in

    r3f12158 r54d714e  
    9292host_triplet = @host@
    9393@BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor
    94 @BUILD_DEBUG_FALSE@am__append_2 = -nodebug
    95 @BUILD_DEBUG_TRUE@@BUILD_RELEASE_FALSE@am__append_3 = -debug
    96 @BUILD_DEBUG_TRUE@@BUILD_RELEASE_TRUE@am__append_4 = ${BUILD_FLAGS}
    9794EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    9895        avl_test$(EXEEXT)
     
    323320
    324321# applies to both programs
    325 DEBUG_FLAGS =
    326 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ \
    327         $(am__append_2) $(am__append_3) $(am__append_4)
     322EXTRA_FLAGS =
     323BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
    328324TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
    329325AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
  • src/tests/test.py

    r3f12158 r54d714e  
    166166
    167167        # build, skipping to next test on error
    168         make_ret, _ = sh("""%s test=yes DEBUG_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
     168        make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
    169169
    170170        retcode = 0
     
    202202                        error = myfile.read()
    203203
    204 
     204               
    205205        # clean the executable
    206206        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
Note: See TracChangeset for help on using the changeset viewer.