Changes in / [85d340d:b1e68d03]
- Files:
-
- 35 added
- 11 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r85d340d rb1e68d03 52 52 tools/prettyprinter/pretty 53 53 tools/pretty 54 tools/catchsig 55 tools/repeat 54 56 55 57 # generated by xfig for user manual -
configure
r85d340d rb1e68d03 6281 6281 6282 6282 6283 ac_config_files="$ac_config_files Makefile src/driver/Makefile src/Makefile src/benchmark/Makefile src/examples/Makefile src/tests/Makefile src/tests/preempt_longrun/Makefile src/prelude/Makefile src/libcfa/Makefile tools/ prettyprinter/Makefile"6283 ac_config_files="$ac_config_files Makefile src/driver/Makefile src/Makefile src/benchmark/Makefile src/examples/Makefile src/tests/Makefile src/tests/preempt_longrun/Makefile src/prelude/Makefile src/libcfa/Makefile tools/Makefile tools/prettyprinter/Makefile" 6284 6284 6285 6285 … … 7048 7048 "src/prelude/Makefile") CONFIG_FILES="$CONFIG_FILES src/prelude/Makefile" ;; 7049 7049 "src/libcfa/Makefile") CONFIG_FILES="$CONFIG_FILES src/libcfa/Makefile" ;; 7050 "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; 7050 7051 "tools/prettyprinter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/prettyprinter/Makefile" ;; 7051 7052 -
configure.ac
r85d340d rb1e68d03 238 238 src/prelude/Makefile 239 239 src/libcfa/Makefile 240 tools/Makefile 240 241 tools/prettyprinter/Makefile 241 242 ]) -
src/Parser/lex.ll
r85d340d rb1e68d03 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Sat Sep 23 17:29:28201713 * Update Count : 63 212 * Last Modified On : Wed Oct 25 13:53:56 2017 13 * Update Count : 634 14 14 */ 15 15 … … 233 233 __extension__ { KEYWORD_RETURN(EXTENSION); } // GCC 234 234 extern { KEYWORD_RETURN(EXTERN); } 235 fallthrough { KEYWORD_RETURN(FALLTHRU); } // CFA236 235 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA 236 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA 237 237 finally { KEYWORD_RETURN(FINALLY); } // CFA 238 238 float { KEYWORD_RETURN(FLOAT); } -
src/Parser/parser.yy
r85d340d rb1e68d03 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 16 11:07:29201713 // Update Count : 289 212 // Last Modified On : Wed Oct 25 12:28:54 2017 13 // Update Count : 2893 14 14 // 15 15 … … 180 180 %token ATTRIBUTE EXTENSION // GCC 181 181 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 182 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA182 %token CHOOSE DISABLE ENABLE FALLTHRU FALLTHROUGH TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA 183 183 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 184 184 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 362 362 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 363 363 364 %locations 364 %locations // support location tracking for error messages 365 365 366 366 %start translation_unit // parse-tree root … … 974 974 ; 975 975 976 fall_through_name: // CFA 977 FALLTHRU 978 | FALLTHROUGH 979 ; 980 976 981 fall_through: // CFA 977 FALLTHRU982 fall_through_name 978 983 { $$ = nullptr; } 979 | FALLTHRU';'984 | fall_through_name ';' 980 985 { $$ = nullptr; } 981 986 ; … … 2486 2491 | TYPEDEFname 2487 2492 | TYPEGENname 2493 | FALLTHROUGH 2494 { $$ = Token{ new string( "fallthrough" ), { nullptr, -1 } }; } 2488 2495 | CONST 2489 2496 { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; } … … 2751 2758 // 2752 2759 // typedef int foo; 2753 // forall( otype T ) foo( T );2760 // forall( otype T ) struct foo; 2754 2761 // int f( int foo ); // redefine typedef name in new scope 2755 2762 // -
src/benchmark/Makefile.am
r85d340d rb1e68d03 19 19 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 20 20 CC = @CFA_BINDIR@/@CFA_NAME@ 21 TOOLSDIR = ${abs_top_srcdir}/tools/ 22 REPEAT = ${TOOLSDIR}repeat 23 STATS = ${TOOLSDIR}stat.py 24 repeats = 30 21 25 22 noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT) 26 .NOTPARALLEL: 27 28 noinst_PROGRAMS = 23 29 24 30 bench$(EXEEXT) : … … 30 36 rm -f ./a.out ; 31 37 32 ctxswitch-coroutine$(EXEEXT):33 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 CorCtxSwitch.c34 @rm -f .result.log35 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \36 ./a.out | tee -a .result.log ; \37 done38 @./stat.py .result.log39 @rm -f a.out .result.log40 41 ctxswitch-thread$(EXEEXT):42 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 ThrdCtxSwitch.c43 @rm -f .result.log44 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \45 ./a.out | tee -a .result.log ; \46 done47 @./stat.py .result.log48 @rm -f a.out .result.log49 50 ctxswitch-pthread$(EXEEXT):51 @BACKEND_CC@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} -lrt -pthread -DN=50000000 PthrdCtxSwitch.c52 @rm -f .result.log53 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \54 ./a.out | tee -a .result.log ; \55 done56 @./stat.py .result.log57 @rm -f a.out .result.log58 59 sched-int$(EXEEXT):60 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 SchedInt.c61 @rm -f .result.log62 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \63 ./a.out | tee -a .result.log ; \64 done65 @./stat.py .result.log66 @rm -f a.out .result.log67 68 monitor$(EXEEXT):69 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 Monitor.c70 @rm -f .result.log71 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \72 ./a.out | tee -a .result.log ; \73 done74 @./stat.py .result.log75 @rm -f a.out .result.log76 77 38 csv-data$(EXEEXT): 78 39 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=50000000 csv-data.c 79 40 @./a.out 80 41 @rm -f ./a.out 42 43 ## ========================================================================================================= 44 ctxswitch$(EXEEXT): \ 45 ctxswitch-pthread.run \ 46 ctxswitch-cfa_coroutine.run \ 47 ctxswitch-cfa_thread.run \ 48 ctxswitch-upp_coroutine.run \ 49 ctxswitch-upp_thread.run 50 51 ctxswitch-cfa_coroutine$(EXEEXT): 52 ${CC} ctxswitch/cfa_cor.c -DBENCH_N=50000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 53 54 ctxswitch-cfa_thread$(EXEEXT): 55 ${CC} ctxswitch/cfa_thrd.c -DBENCH_N=50000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 56 57 ctxswitch-upp_coroutine$(EXEEXT): 58 u++ ctxswitch/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 59 60 ctxswitch-upp_thread$(EXEEXT): 61 u++ ctxswitch/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 62 63 ctxswitch-pthread$(EXEEXT): 64 @BACKEND_CC@ ctxswitch/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 65 66 ## ========================================================================================================= 67 creation$(EXEEXT) :\ 68 creation-pthread.run \ 69 creation-cfa_coroutine.run \ 70 creation-cfa_thread.run \ 71 creation-upp_coroutine.run \ 72 creation-upp_thread.run 73 74 creation-cfa_coroutine$(EXEEXT): 75 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 76 77 creation-cfa_thread$(EXEEXT): 78 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 79 80 creation-upp_coroutine$(EXEEXT): 81 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 82 83 creation-upp_thread$(EXEEXT): 84 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 85 86 creation-pthread$(EXEEXT): 87 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 88 89 ## ========================================================================================================= 90 mutex$(EXEEXT) :\ 91 mutex-function.run \ 92 mutex-pthread_lock.run \ 93 mutex-upp.run \ 94 mutex-cfa1.run \ 95 mutex-cfa2.run \ 96 mutex-cfa4.run 97 98 mutex-function$(EXEEXT): 99 @BACKEND_CC@ mutex/function.c -DBENCH_N=500000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 100 101 mutex-pthread_lock$(EXEEXT): 102 @BACKEND_CC@ mutex/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 103 104 mutex-upp$(EXEEXT): 105 u++ mutex/upp.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 106 107 mutex-cfa1$(EXEEXT): 108 ${CC} mutex/cfa1.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 109 110 mutex-cfa2$(EXEEXT): 111 ${CC} mutex/cfa2.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 112 113 mutex-cfa4$(EXEEXT): 114 ${CC} mutex/cfa4.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 115 116 ## ========================================================================================================= 117 signal$(EXEEXT) :\ 118 signal-upp.run \ 119 signal-cfa1.run \ 120 signal-cfa2.run \ 121 signal-cfa4.run 122 123 signal-upp$(EXEEXT): 124 u++ schedint/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 125 126 signal-cfa1$(EXEEXT): 127 ${CC} schedint/cfa1.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 128 129 signal-cfa2$(EXEEXT): 130 ${CC} schedint/cfa2.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 131 132 signal-cfa4$(EXEEXT): 133 ${CC} schedint/cfa4.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 134 135 ## ========================================================================================================= 136 waitfor$(EXEEXT) :\ 137 waitfor-upp.run \ 138 waitfor-cfa1.run \ 139 waitfor-cfa2.run \ 140 waitfor-cfa4.run 141 142 waitfor-upp$(EXEEXT): 143 u++ schedext/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 144 145 waitfor-cfa1$(EXEEXT): 146 ${CC} schedext/cfa1.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 147 148 waitfor-cfa2$(EXEEXT): 149 ${CC} schedext/cfa2.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 150 151 waitfor-cfa4$(EXEEXT): 152 ${CC} schedext/cfa4.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 153 154 ## ========================================================================================================= 155 156 %.run : %$(EXEEXT) ${REPEAT} 157 @rm -f .result.log 158 @echo "------------------------------------------------------" 159 @echo $< 160 @${REPEAT} ${repeats} ./a.out | tee -a .result.log 161 @${STATS} .result.log 162 @echo "------------------------------------------------------" 163 @rm -f a.out .result.log 164 165 ${REPEAT} : 166 @+make -C ${TOOLSDIR} repeat -
src/benchmark/Makefile.in
r85d340d rb1e68d03 92 92 build_triplet = @build@ 93 93 host_triplet = @host@ 94 noinst_PROGRAMS = 94 95 subdir = src/benchmark 95 96 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 103 104 CONFIG_CLEAN_VPATH_FILES = 104 105 PROGRAMS = $(noinst_PROGRAMS) 105 bench_SOURCES = bench.c106 bench_OBJECTS = bench.$(OBJEXT)107 bench_LDADD = $(LDADD)108 csv_data_SOURCES = csv-data.c109 csv_data_OBJECTS = csv-data.$(OBJEXT)110 csv_data_LDADD = $(LDADD)111 ctxswitch_coroutine_SOURCES = ctxswitch-coroutine.c112 ctxswitch_coroutine_OBJECTS = ctxswitch-coroutine.$(OBJEXT)113 ctxswitch_coroutine_LDADD = $(LDADD)114 ctxswitch_thread_SOURCES = ctxswitch-thread.c115 ctxswitch_thread_OBJECTS = ctxswitch-thread.$(OBJEXT)116 ctxswitch_thread_LDADD = $(LDADD)117 monitor_SOURCES = monitor.c118 monitor_OBJECTS = monitor.$(OBJEXT)119 monitor_LDADD = $(LDADD)120 sched_int_SOURCES = sched-int.c121 sched_int_OBJECTS = sched-int.$(OBJEXT)122 sched_int_LDADD = $(LDADD)123 106 AM_V_P = $(am__v_P_@AM_V@) 124 107 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) … … 133 116 am__v_at_0 = @ 134 117 am__v_at_1 = 135 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 136 depcomp = $(SHELL) $(top_srcdir)/automake/depcomp 137 am__depfiles_maybe = depfiles 138 am__mv = mv -f 139 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 140 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 141 AM_V_CC = $(am__v_CC_@AM_V@) 142 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 143 am__v_CC_0 = @echo " CC " $@; 144 am__v_CC_1 = 145 CCLD = $(CC) 146 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 147 AM_V_CCLD = $(am__v_CCLD_@AM_V@) 148 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 149 am__v_CCLD_0 = @echo " CCLD " $@; 150 am__v_CCLD_1 = 151 SOURCES = bench.c csv-data.c ctxswitch-coroutine.c ctxswitch-thread.c \ 152 monitor.c sched-int.c 153 DIST_SOURCES = bench.c csv-data.c ctxswitch-coroutine.c \ 154 ctxswitch-thread.c monitor.c sched-int.c 118 SOURCES = 119 DIST_SOURCES = 155 120 am__can_run_installinfo = \ 156 121 case $$AM_UPDATE_INFO_DIR in \ … … 159 124 esac 160 125 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 161 # Read a list of newline-separated strings from the standard input, 162 # and print each of them once, without duplicates. Input order is 163 # *not* preserved. 164 am__uniquify_input = $(AWK) '\ 165 BEGIN { nonempty = 0; } \ 166 { items[$$0] = 1; nonempty = 1; } \ 167 END { if (nonempty) { for (i in items) print i; }; } \ 168 ' 169 # Make sure the list of sources is unique. This is necessary because, 170 # e.g., the same source file might be shared among _SOURCES variables 171 # for different programs/libraries. 172 am__define_uniq_tagged_files = \ 173 list='$(am__tagged_files)'; \ 174 unique=`for i in $$list; do \ 175 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 176 done | $(am__uniquify_input)` 177 ETAGS = etags 178 CTAGS = ctags 179 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/automake/depcomp 126 am__DIST_COMMON = $(srcdir)/Makefile.in 180 127 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 181 128 ACLOCAL = @ACLOCAL@ … … 302 249 top_srcdir = @top_srcdir@ 303 250 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 304 noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT) 251 TOOLSDIR = ${abs_top_srcdir}/tools/ 252 REPEAT = ${TOOLSDIR}repeat 253 STATS = ${TOOLSDIR}stat.py 254 repeats = 30 305 255 all: all-am 306 256 307 257 .SUFFIXES: 308 .SUFFIXES: .c .o .obj309 258 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 310 259 @for dep in $?; do \ … … 339 288 clean-noinstPROGRAMS: 340 289 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) 341 342 mostlyclean-compile: 343 -rm -f *.$(OBJEXT) 344 345 distclean-compile: 346 -rm -f *.tab.c 347 348 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bench.Po@am__quote@ 349 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/csv-data.Po@am__quote@ 350 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctxswitch-coroutine.Po@am__quote@ 351 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctxswitch-thread.Po@am__quote@ 352 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@ 353 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sched-int.Po@am__quote@ 354 355 .c.o: 356 @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ 357 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ 358 @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po 359 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 360 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 361 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 362 363 .c.obj: 364 @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ 365 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ 366 @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po 367 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 368 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 369 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 370 371 ID: $(am__tagged_files) 372 $(am__define_uniq_tagged_files); mkid -fID $$unique 373 tags: tags-am 374 TAGS: tags 375 376 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 377 set x; \ 378 here=`pwd`; \ 379 $(am__define_uniq_tagged_files); \ 380 shift; \ 381 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 382 test -n "$$unique" || unique=$$empty_fix; \ 383 if test $$# -gt 0; then \ 384 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 385 "$$@" $$unique; \ 386 else \ 387 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 388 $$unique; \ 389 fi; \ 390 fi 391 ctags: ctags-am 392 393 CTAGS: ctags 394 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 395 $(am__define_uniq_tagged_files); \ 396 test -z "$(CTAGS_ARGS)$$unique" \ 397 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 398 $$unique 399 400 GTAGS: 401 here=`$(am__cd) $(top_builddir) && pwd` \ 402 && $(am__cd) $(top_srcdir) \ 403 && gtags -i $(GTAGS_ARGS) "$$here" 404 cscopelist: cscopelist-am 405 406 cscopelist-am: $(am__tagged_files) 407 list='$(am__tagged_files)'; \ 408 case "$(srcdir)" in \ 409 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 410 *) sdir=$(subdir)/$(srcdir) ;; \ 411 esac; \ 412 for i in $$list; do \ 413 if test -f "$$i"; then \ 414 echo "$(subdir)/$$i"; \ 415 else \ 416 echo "$$sdir/$$i"; \ 417 fi; \ 418 done >> $(top_builddir)/cscope.files 419 420 distclean-tags: 421 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 290 tags TAGS: 291 292 ctags CTAGS: 293 294 cscope cscopelist: 295 422 296 423 297 distdir: $(DISTFILES) … … 490 364 491 365 distclean: distclean-am 492 -rm -rf ./$(DEPDIR)493 366 -rm -f Makefile 494 distclean-am: clean-am distclean-compile distclean-generic \ 495 distclean-tags 367 distclean-am: clean-am distclean-generic 496 368 497 369 dvi: dvi-am … … 536 408 537 409 maintainer-clean: maintainer-clean-am 538 -rm -rf ./$(DEPDIR)539 410 -rm -f Makefile 540 411 maintainer-clean-am: distclean-am maintainer-clean-generic … … 542 413 mostlyclean: mostlyclean-am 543 414 544 mostlyclean-am: mostlyclean- compile mostlyclean-generic415 mostlyclean-am: mostlyclean-generic 545 416 546 417 pdf: pdf-am … … 556 427 .MAKE: install-am install-strip 557 428 558 .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ 559 clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ 560 distclean-compile distclean-generic distclean-tags distdir dvi \ 561 dvi-am html html-am info info-am install install-am \ 562 install-data install-data-am install-dvi install-dvi-am \ 563 install-exec install-exec-am install-html install-html-am \ 564 install-info install-info-am install-man install-pdf \ 565 install-pdf-am install-ps install-ps-am install-strip \ 566 installcheck installcheck-am installdirs maintainer-clean \ 567 maintainer-clean-generic mostlyclean mostlyclean-compile \ 568 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ 429 .PHONY: all all-am check check-am clean clean-generic \ 430 clean-noinstPROGRAMS cscopelist-am ctags-am distclean \ 431 distclean-generic distdir dvi dvi-am html html-am info info-am \ 432 install install-am install-data install-data-am install-dvi \ 433 install-dvi-am install-exec install-exec-am install-html \ 434 install-html-am install-info install-info-am install-man \ 435 install-pdf install-pdf-am install-ps install-ps-am \ 436 install-strip installcheck installcheck-am installdirs \ 437 maintainer-clean maintainer-clean-generic mostlyclean \ 438 mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \ 569 439 uninstall-am 570 440 571 441 .PRECIOUS: Makefile 572 442 443 444 .NOTPARALLEL: 573 445 574 446 bench$(EXEEXT) : … … 580 452 rm -f ./a.out ; 581 453 582 ctxswitch-coroutine$(EXEEXT):583 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 CorCtxSwitch.c584 @rm -f .result.log585 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \586 ./a.out | tee -a .result.log ; \587 done588 @./stat.py .result.log589 @rm -f a.out .result.log590 591 ctxswitch-thread$(EXEEXT):592 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 ThrdCtxSwitch.c593 @rm -f .result.log594 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \595 ./a.out | tee -a .result.log ; \596 done597 @./stat.py .result.log598 @rm -f a.out .result.log599 600 ctxswitch-pthread$(EXEEXT):601 @BACKEND_CC@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} -lrt -pthread -DN=50000000 PthrdCtxSwitch.c602 @rm -f .result.log603 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \604 ./a.out | tee -a .result.log ; \605 done606 @./stat.py .result.log607 @rm -f a.out .result.log608 609 sched-int$(EXEEXT):610 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 SchedInt.c611 @rm -f .result.log612 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \613 ./a.out | tee -a .result.log ; \614 done615 @./stat.py .result.log616 @rm -f a.out .result.log617 618 monitor$(EXEEXT):619 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 Monitor.c620 @rm -f .result.log621 @for number in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do \622 ./a.out | tee -a .result.log ; \623 done624 @./stat.py .result.log625 @rm -f a.out .result.log626 627 454 csv-data$(EXEEXT): 628 455 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=50000000 csv-data.c … … 630 457 @rm -f ./a.out 631 458 459 ctxswitch$(EXEEXT): \ 460 ctxswitch-pthread.run \ 461 ctxswitch-cfa_coroutine.run \ 462 ctxswitch-cfa_thread.run \ 463 ctxswitch-upp_coroutine.run \ 464 ctxswitch-upp_thread.run 465 466 ctxswitch-cfa_coroutine$(EXEEXT): 467 ${CC} ctxswitch/cfa_cor.c -DBENCH_N=50000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 468 469 ctxswitch-cfa_thread$(EXEEXT): 470 ${CC} ctxswitch/cfa_thrd.c -DBENCH_N=50000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 471 472 ctxswitch-upp_coroutine$(EXEEXT): 473 u++ ctxswitch/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 474 475 ctxswitch-upp_thread$(EXEEXT): 476 u++ ctxswitch/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 477 478 ctxswitch-pthread$(EXEEXT): 479 @BACKEND_CC@ ctxswitch/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 480 481 creation$(EXEEXT) :\ 482 creation-pthread.run \ 483 creation-cfa_coroutine.run \ 484 creation-cfa_thread.run \ 485 creation-upp_coroutine.run \ 486 creation-upp_thread.run 487 488 creation-cfa_coroutine$(EXEEXT): 489 ${CC} creation/cfa_cor.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 490 491 creation-cfa_thread$(EXEEXT): 492 ${CC} creation/cfa_thrd.c -DBENCH_N=10000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 493 494 creation-upp_coroutine$(EXEEXT): 495 u++ creation/upp_cor.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 496 497 creation-upp_thread$(EXEEXT): 498 u++ creation/upp_thrd.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 499 500 creation-pthread$(EXEEXT): 501 @BACKEND_CC@ creation/pthreads.c -DBENCH_N=250000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 502 503 mutex$(EXEEXT) :\ 504 mutex-function.run \ 505 mutex-pthread_lock.run \ 506 mutex-upp.run \ 507 mutex-cfa1.run \ 508 mutex-cfa2.run \ 509 mutex-cfa4.run 510 511 mutex-function$(EXEEXT): 512 @BACKEND_CC@ mutex/function.c -DBENCH_N=500000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 513 514 mutex-pthread_lock$(EXEEXT): 515 @BACKEND_CC@ mutex/pthreads.c -DBENCH_N=50000000 -I. -lrt -pthread ${AM_CFLAGS} ${CFLAGS} ${ccflags} 516 517 mutex-upp$(EXEEXT): 518 u++ mutex/upp.cc -DBENCH_N=50000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 519 520 mutex-cfa1$(EXEEXT): 521 ${CC} mutex/cfa1.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 522 523 mutex-cfa2$(EXEEXT): 524 ${CC} mutex/cfa2.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 525 526 mutex-cfa4$(EXEEXT): 527 ${CC} mutex/cfa4.c -DBENCH_N=5000000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 528 529 signal$(EXEEXT) :\ 530 signal-upp.run \ 531 signal-cfa1.run \ 532 signal-cfa2.run \ 533 signal-cfa4.run 534 535 signal-upp$(EXEEXT): 536 u++ schedint/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 537 538 signal-cfa1$(EXEEXT): 539 ${CC} schedint/cfa1.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 540 541 signal-cfa2$(EXEEXT): 542 ${CC} schedint/cfa2.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 543 544 signal-cfa4$(EXEEXT): 545 ${CC} schedint/cfa4.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 546 547 waitfor$(EXEEXT) :\ 548 waitfor-upp.run \ 549 waitfor-cfa1.run \ 550 waitfor-cfa2.run \ 551 waitfor-cfa4.run 552 553 waitfor-upp$(EXEEXT): 554 u++ schedext/upp.cc -DBENCH_N=5000000 -I. -nodebug -lrt -quiet ${AM_CFLAGS} ${CFLAGS} ${ccflags} 555 556 waitfor-cfa1$(EXEEXT): 557 ${CC} schedext/cfa1.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 558 559 waitfor-cfa2$(EXEEXT): 560 ${CC} schedext/cfa2.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 561 562 waitfor-cfa4$(EXEEXT): 563 ${CC} schedext/cfa4.c -DBENCH_N=500000 -I. -nodebug -lrt -quiet @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 564 565 %.run : %$(EXEEXT) ${REPEAT} 566 @rm -f .result.log 567 @echo "------------------------------------------------------" 568 @echo $< 569 @${REPEAT} ${repeats} ./a.out | tee -a .result.log 570 @${STATS} .result.log 571 @echo "------------------------------------------------------" 572 @rm -f a.out .result.log 573 574 ${REPEAT} : 575 @+make -C ${TOOLSDIR} repeat 576 632 577 # Tell versions [3.59,3.63) of GNU make to not export all variables. 633 578 # Otherwise a system limit (for SysV at least) may be exceeded. -
src/benchmark/bench.h
r85d340d rb1e68d03 1 1 #pragma once 2 2 3 #if def __CFORALL__3 #if defined(__CFORALL__) 4 4 extern "C" { 5 5 #endif 6 #include <stdlib.h> 6 7 #include <unistd.h> // sysconf 7 8 #include <sys/times.h> // times 8 9 #include <time.h> 9 #if def __CFORALL__10 #if defined(__CFORALL__) 10 11 } 11 12 #endif … … 27 28 } // Time 28 29 29 #ifndef N30 #define N1000000030 #ifndef BENCH_N 31 #define BENCH_N 500 //10000000 31 32 #endif 33 34 #define BENCH(statement, output) \ 35 size_t n = BENCH_N; \ 36 if( argc > 2 ) return 1; \ 37 if( argc == 2 ) { \ 38 n = atoi(argv[1]); \ 39 } \ 40 long long int StartTime, EndTime; \ 41 StartTime = Time(); \ 42 statement; \ 43 EndTime = Time(); \ 44 unsigned long long int output = \ 45 ( EndTime - StartTime ) / n; 32 46 33 47 unsigned int default_preemption() { -
src/driver/cfa.cc
r85d340d rb1e68d03 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Sep 26 23:12:38201713 // Update Count : 1 5912 // Last Modified On : Tue Oct 31 11:40:44 2017 13 // Update Count : 160 14 14 // 15 15 … … 305 305 } // if 306 306 307 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list 308 nargs += 1; 307 309 if ( CFA_flag ) { 310 args[sargs] = "-D__CFA_FLAG__=-N"; 308 311 args[nargs] = "-D__CFA_PREPROCESS_"; 309 312 nargs += 1; 310 } // if 313 } else { 314 args[sargs] = "-D__CFA_FLAG__=-L"; 315 } // if 316 sargs += 1; 311 317 312 318 if ( debug ) { -
src/libcfa/concurrency/kernel.c
r85d340d rb1e68d03 548 548 549 549 int len = snprintf( abort_text, abort_text_size, "Error occurred while executing task %.256s (%p)", thrd->self_cor.name, thrd ); 550 __lib_debug_write( STDERR_FILENO,abort_text, len );550 __lib_debug_write( abort_text, len ); 551 551 552 552 if ( thrd != this_coroutine ) { 553 553 len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", this_coroutine->name, this_coroutine ); 554 __lib_debug_write( STDERR_FILENO,abort_text, len );554 __lib_debug_write( abort_text, len ); 555 555 } 556 556 else { 557 __lib_debug_write( STDERR_FILENO,".\n", 2 );557 __lib_debug_write( ".\n", 2 ); 558 558 } 559 559 } -
src/libcfa/concurrency/monitor.c
r85d340d rb1e68d03 21 21 #include "kernel_private.h" 22 22 23 #include "bits/algorithms.h" 24 23 25 //----------------------------------------------------------------------------- 24 26 // Forward declarations … … 95 97 else if( this->owner == thrd) { 96 98 // We already have the monitor, just note how many times we took it 97 verify( this->recursion > 0 );98 99 this->recursion += 1; 99 100 … … 207 208 // it means we don't need to do anything 208 209 if( this->recursion != 0) { 210 LIB_DEBUG_PRINT_SAFE("Kernel : recursion still %d\n", this->recursion); 209 211 unlock( &this->lock ); 210 212 return; … … 291 293 292 294 // Sort monitors based on address -> TODO use a sort specialized for small numbers 293 qsort(this.m, count);295 __libcfa_small_sort(this.m, count); 294 296 295 297 // Save previous thread context … … 492 494 set_owner( monitors, count, signallee ); 493 495 496 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", this, signallee ); 497 494 498 //Everything is ready to go to sleep 495 499 BlockInternal( locks, count, &signallee, 1 ); … … 498 502 // WE WOKE UP 499 503 504 505 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : signal_block returned\n" ); 500 506 501 507 //We are back, restore the masks and recursions … … 536 542 short actual_count = aggregate( mon_storage, mask ); 537 543 538 LIB_DEBUG_PRINT_ SAFE("Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max);544 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max); 539 545 540 546 if(actual_count == 0) return; 541 547 542 LIB_DEBUG_PRINT_ SAFE("Kernel : waitfor internal proceeding\n");548 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : waitfor internal proceeding\n"); 543 549 544 550 // Create storage for monitor context … … 556 562 *mask.accepted = index; 557 563 if( mask.clauses[index].is_dtor ) { 558 LIB_DEBUG_PRINT_ SAFE("Kernel : dtor already there\n");564 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : dtor already there\n"); 559 565 verifyf( mask.clauses[index].size == 1 , "ERROR: Accepted dtor has more than 1 mutex parameter." ); 560 566 … … 568 574 } 569 575 else { 570 LIB_DEBUG_PRINT_ SAFE("Kernel : thread present, baton-passing\n");576 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : thread present, baton-passing\n"); 571 577 572 578 // Create the node specific to this wait operation … … 576 582 monitor_save; 577 583 584 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : baton of %d monitors : ", count ); 585 #ifdef __CFA_DEBUG_PRINT__ 586 for( int i = 0; i < count; i++) { 587 LIB_DEBUG_PRINT_BUFFER_LOCAL( "%p %p ", monitors[i], monitors[i]->signal_stack.top ); 588 } 589 #endif 590 LIB_DEBUG_PRINT_BUFFER_LOCAL( "\n"); 591 578 592 // Set the owners to be the next thread 579 593 set_owner( monitors, count, next ); … … 585 599 monitor_restore; 586 600 587 LIB_DEBUG_PRINT_ SAFE("Kernel : thread present, returned\n");601 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : thread present, returned\n"); 588 602 } 589 603 590 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);604 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 591 605 592 606 return; … … 596 610 597 611 if( duration == 0 ) { 598 LIB_DEBUG_PRINT_ SAFE("Kernel : non-blocking, exiting\n");612 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : non-blocking, exiting\n"); 599 613 600 614 unlock_all( locks, count ); 601 615 602 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);616 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 603 617 return; 604 618 } … … 607 621 verifyf( duration < 0, "Timeout on waitfor statments not supported yet."); 608 622 609 LIB_DEBUG_PRINT_ SAFE("Kernel : blocking waitfor\n");623 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : blocking waitfor\n"); 610 624 611 625 // Create the node specific to this wait operation … … 629 643 monitor_restore; 630 644 631 LIB_DEBUG_PRINT_ SAFE("Kernel : exiting\n");632 633 LIB_DEBUG_PRINT_ SAFE("Kernel : accepted %d\n", *mask.accepted);645 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : exiting\n"); 646 647 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : accepted %d\n", *mask.accepted); 634 648 } 635 649 … … 648 662 649 663 static inline void set_owner( monitor_desc ** monitors, short count, thread_desc * owner ) { 650 for( int i = 0; i < count; i++ ) { 651 set_owner( monitors[i], owner ); 664 monitors[0]->owner = owner; 665 monitors[0]->recursion = 1; 666 for( int i = 1; i < count; i++ ) { 667 monitors[i]->owner = owner; 668 monitors[i]->recursion = 0; 652 669 } 653 670 } … … 667 684 static inline thread_desc * next_thread( monitor_desc * this ) { 668 685 //Check the signaller stack 686 LIB_DEBUG_PRINT_SAFE("Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top); 669 687 __condition_criterion_t * urgent = pop( &this->signal_stack ); 670 688 if( urgent ) { … … 718 736 for(int i = 0; i < count; i++) { 719 737 (criteria[i]){ monitors[i], waiter }; 738 LIB_DEBUG_PRINT_SAFE( "Kernel : target %p = %p\n", criteria[i].target, &criteria[i] ); 720 739 push( &criteria[i].target->signal_stack, &criteria[i] ); 721 740 } … … 788 807 } 789 808 790 // LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run);809 LIB_DEBUG_PRINT_SAFE( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL ); 791 810 return ready2run ? node->waiting_thread : NULL; 792 811 } … … 856 875 short size = 0; 857 876 for( int i = 0; i < mask.size; i++ ) { 877 __libcfa_small_sort( mask.clauses[i].list, mask.clauses[i].size ); 858 878 for( int j = 0; j < mask.clauses[i].size; j++) { 859 879 insert_unique( storage, size, mask.clauses[i].list[j] ); 860 880 } 861 881 } 862 qsort( storage, size ); 882 // TODO insertion sort instead of this 883 __libcfa_small_sort( storage, size ); 863 884 return size; 864 885 } -
src/libcfa/concurrency/preemption.c
r85d340d rb1e68d03 380 380 381 381 if ( sigaction( sig, &act, NULL ) == -1 ) { 382 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,382 LIB_DEBUG_PRINT_BUFFER_DECL( 383 383 " __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", 384 384 sig, handler, flags, errno, strerror( errno ) … … 397 397 398 398 if ( sigaction( sig, &act, NULL ) == -1 ) { 399 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO,399 LIB_DEBUG_PRINT_BUFFER_DECL( 400 400 " __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 401 401 sig, errno, strerror( errno ) -
src/libcfa/interpose.c
r85d340d rb1e68d03 127 127 va_end( args ); 128 128 129 __lib_debug_write( STDERR_FILENO,abort_text, len );130 __lib_debug_write( STDERR_FILENO,"\n", 1 );129 __lib_debug_write( abort_text, len ); 130 __lib_debug_write( "\n", 1 ); 131 131 } 132 132 133 133 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld)\n", (long int)getpid() ); // use UNIX pid (versus getPid) 134 __lib_debug_write( STDERR_FILENO,abort_text, len );134 __lib_debug_write( abort_text, len ); 135 135 136 136 -
src/libcfa/libhdr/libdebug.c
r85d340d rb1e68d03 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 // Last Modified By : 12 // Last Modified On : 11 // Last Modified By : 12 // Last Modified On : 13 13 // Update Count : 0 14 14 // … … 28 28 extern "C" { 29 29 30 void __lib_debug_write( int fd,const char *in_buffer, int len ) {30 void __lib_debug_write( const char *in_buffer, int len ) { 31 31 // ensure all data is written 32 for ( int count = 0, retcode; count < len; count += retcode ) { 32 for ( int count = 0, retcode; count < len; count += retcode ) { 33 33 in_buffer += count; 34 34 35 35 for ( ;; ) { 36 retcode = write( fd, in_buffer, len - count );36 retcode = write( STDERR_FILENO, in_buffer, len - count ); 37 37 38 38 // not a timer interrupt ? 39 if ( retcode != -1 || errno != EINTR ) break; 39 if ( retcode != -1 || errno != EINTR ) break; 40 40 } 41 41 … … 52 52 va_start( args, fmt ); 53 53 __lib_debug_acquire(); 54 54 55 55 int len = vsnprintf( buffer, buffer_size, fmt, args ); 56 __lib_debug_write( STDERR_FILENO,buffer, len );56 __lib_debug_write( buffer, len ); 57 57 58 58 __lib_debug_release(); … … 64 64 65 65 va_start( args, fmt ); 66 66 67 67 int len = vsnprintf( buffer, buffer_size, fmt, args ); 68 __lib_debug_write( STDERR_FILENO,buffer, len );68 __lib_debug_write( buffer, len ); 69 69 70 70 va_end( args ); … … 73 73 void __lib_debug_print_vararg( const char fmt[], va_list args ) { 74 74 int len = vsnprintf( buffer, buffer_size, fmt, args ); 75 __lib_debug_write( STDERR_FILENO,buffer, len );75 __lib_debug_write( buffer, len ); 76 76 } 77 77 … … 80 80 81 81 va_start( args, fmt ); 82 82 83 83 int len = vsnprintf( in_buffer, in_buffer_size, fmt, args ); 84 __lib_debug_write( STDERR_FILENO,in_buffer, len );84 __lib_debug_write( in_buffer, len ); 85 85 86 86 va_end( args ); -
src/libcfa/libhdr/libdebug.h
r85d340d rb1e68d03 44 44 extern "C" { 45 45 #endif 46 #include <stdarg.h> 46 #include <stdarg.h> 47 #include <stdio.h> 47 48 48 extern void __lib_debug_write( int fd,const char *buffer, int len );49 extern void __lib_debug_write( const char *buffer, int len ); 49 50 extern void __lib_debug_acquire(); 50 51 extern void __lib_debug_release(); … … 58 59 59 60 #ifdef __CFA_DEBUG_PRINT__ 60 #define LIB_DEBUG_WRITE( fd, buffer, len ) __lib_debug_write( fd,buffer, len )61 #define LIB_DEBUG_WRITE( buffer, len ) __lib_debug_write( buffer, len ) 61 62 #define LIB_DEBUG_ACQUIRE() __lib_debug_acquire() 62 63 #define LIB_DEBUG_RELEASE() __lib_debug_release() … … 64 65 #define LIB_DEBUG_PRINT_NOLOCK(...) __lib_debug_print_nolock (__VA_ARGS__) 65 66 #define LIB_DEBUG_PRINT_BUFFER(...) __lib_debug_print_buffer (__VA_ARGS__) 66 #define LIB_DEBUG_PRINT_BUFFER_DECL( fd, ...) char text[256]; int len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text,len );67 #define LIB_DEBUG_PRINT_BUFFER_LOCAL( fd, ...) len = snprintf( text, 256, __VA_ARGS__ ); __lib_debug_write( fd, text,len );67 #define LIB_DEBUG_PRINT_BUFFER_DECL(...) char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len ); 68 #define LIB_DEBUG_PRINT_BUFFER_LOCAL(...) __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __lib_debug_write( __dbg_text, __dbg_len ); 68 69 #else 69 70 #define LIB_DEBUG_WRITE(...) ((void)0) -
src/libcfa/stdlib
r85d340d rb1e68d03 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 20:29:47201713 // Update Count : 2 2412 // Last Modified On : Tue Oct 31 13:47:24 2017 13 // Update Count : 245 14 14 // 15 15 … … 27 27 // allocation, non-array types 28 28 static inline forall( dtype T | sized(T) ) T * malloc( void ) { 29 // printf( "X1\n" );29 // printf( "* malloc\n" ); 30 30 return (T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 31 31 } // malloc 32 33 // static inline forall( dtype T | sized(T) ) T & malloc( void ) { 34 // int & p = *(T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 35 // printf( "& malloc %p\n", &p ); 36 // return p; 37 // // return (T &)*(T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc 38 // } // malloc 32 39 33 40 extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine … … 206 213 //--------------------------------------- 207 214 208 void rand48seed( long int s ); 209 char rand48( void ); 210 int rand48( void ); 211 unsigned int rand48( void ); 212 long int rand48( void ); 213 unsigned long int rand48( void ); 214 float rand48( void ); 215 double rand48( void ); 216 float _Complex rand48( void ); 217 double _Complex rand48( void ); 218 long double _Complex rand48( void ); 215 void random_seed( long int s ); 216 char random( void ); 217 char random( char l, char u ); 218 int random( void ); 219 unsigned int random( void ); 220 unsigned int random( unsigned int u ); 221 unsigned int random( unsigned int l, unsigned int u ); 222 //long int random( void ); 223 unsigned long int random( void ); 224 unsigned long int random( unsigned long int u ); 225 unsigned long int random( unsigned long int l, unsigned long int u ); 226 float random( void ); 227 double random( void ); 228 float _Complex random( void ); 229 double _Complex random( void ); 230 long double _Complex random( void ); 219 231 220 232 //--------------------------------------- -
src/libcfa/stdlib.c
r85d340d rb1e68d03 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 20:30:44201713 // Update Count : 29 212 // Last Modified On : Mon Oct 30 22:43:02 2017 13 // Update Count : 297 14 14 // 15 15 … … 275 275 //--------------------------------------- 276 276 277 void rand48seed( long int s ) { srand48( s ); } 278 char rand48( void ) { return mrand48(); } 279 int rand48( void ) { return mrand48(); } 280 unsigned int rand48( void ) { return lrand48(); } 281 long int rand48( void ) { return mrand48(); } 282 unsigned long int rand48( void ) { return lrand48(); } 283 float rand48( void ) { return (float)drand48(); } // otherwise float uses lrand48 284 double rand48( void ) { return drand48(); } 285 float _Complex rand48( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 286 double _Complex rand48( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 287 long double _Complex rand48( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 277 void random_seed( long int s ) { srand48( s ); } 278 char random( void ) { return mrand48(); } 279 char random( char l, char u ) { return lrand48() % (u - l) + l; } 280 int random( void ) { return mrand48(); } 281 unsigned int random( void ) { return lrand48(); } 282 unsigned int random( unsigned int u ) { return lrand48() % u; } 283 unsigned int random( unsigned int l, unsigned int u ) { return lrand48() % (u - l) + l; } 284 //long int random( void ) { return mrand48(); } 285 unsigned long int random( void ) { return lrand48(); } 286 unsigned long int random( unsigned long int u ) { return lrand48() % u; } 287 unsigned long int random( unsigned long int l, unsigned long int u ) { return lrand48() % (u - l) + l; } 288 float random( void ) { return (float)drand48(); } // otherwise float uses lrand48 289 double random( void ) { return drand48(); } 290 float _Complex random( void ) { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); } 291 double _Complex random( void ) { return drand48() + (double _Complex)(drand48() * _Complex_I); } 292 long double _Complex random( void) { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); } 288 293 289 294 //--------------------------------------- -
src/main.cc
r85d340d rb1e68d03 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Andrew Beach13 // Last Modified On : Wed Jul 26 14:38:00 201714 // Update Count : 44 312 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Tue Oct 31 12:22:40 2017 14 // Update Count : 445 15 15 // 16 16 … … 81 81 expraltp = false, 82 82 libcfap = false, 83 preludep = false, 83 84 nopreludep = false, 84 85 noprotop = false, … … 378 379 379 380 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 380 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };381 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Preamble, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, }; 381 382 382 383 static struct option long_opts[] = { … … 390 391 { "grammar", no_argument, 0, Grammar }, 391 392 { "libcfa", no_argument, 0, LibCFA }, 393 { "preamble", no_argument, 0, Preamble }, 392 394 { "no-preamble", no_argument, 0, Nopreamble }, 393 395 { "parse", no_argument, 0, Parse }, … … 405 407 406 408 int c; 407 while ( (c = getopt_long( argc, argv, "abBcCdefglLmn pqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {409 while ( (c = getopt_long( argc, argv, "abBcCdefglLmnNpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 408 410 switch ( c ) { 409 411 case Ast: … … 451 453 case 'n': // do not read preamble 452 454 nopreludep = true; 455 break; 456 case Preamble: 457 case 'N': // read preamble 458 preludep = true; 453 459 break; 454 460 case Prototypes: -
src/prelude/prelude.cf
r85d340d rb1e68d03 7 7 // Created On : Sat Nov 29 07:23:41 2014 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : S un Oct 8 12:21:33201710 // Update Count : 979 // Last Modified On : Sat Oct 28 16:33:09 2017 10 // Update Count : 102 11 11 // 12 12 … … 41 41 _Bool ?++( _Bool & ), ?++( volatile _Bool & ); 42 42 _Bool ?--( _Bool & ), ?--( volatile _Bool & ); 43 unsigned char ?++( unsigned char & ), ?++( volatile unsigned char & );44 43 signed short ?++( signed short & ), ?++( volatile signed short & ); 45 44 signed short ?--( signed short & ), ?--( volatile signed short & ); … … 196 195 long double _Complex ?+?( long double _Complex, long double _Complex ), ?-?( long double _Complex, long double _Complex ); 197 196 198 forall( dtype T | sized(T) ) T * 199 forall( dtype T | sized(T) ) T * 197 forall( dtype T | sized(T) ) T * ?+?( T *, ptrdiff_t ); 198 forall( dtype T | sized(T) ) T * ?+?( ptrdiff_t, T * ); 200 199 forall( dtype T | sized(T) ) const T * ?+?( const T *, ptrdiff_t ); 201 200 forall( dtype T | sized(T) ) const T * ?+?( ptrdiff_t, const T * ); 202 forall( dtype T | sized(T) ) volatile T * 203 forall( dtype T | sized(T) ) volatile T * 201 forall( dtype T | sized(T) ) volatile T * ?+?( volatile T *, ptrdiff_t ); 202 forall( dtype T | sized(T) ) volatile T * ?+?( ptrdiff_t, volatile T * ); 204 203 forall( dtype T | sized(T) ) const volatile T * ?+?( const volatile T *, ptrdiff_t ); 205 204 forall( dtype T | sized(T) ) const volatile T * ?+?( ptrdiff_t, const volatile T * ); 206 forall( dtype T | sized(T) ) T * 205 forall( dtype T | sized(T) ) T * ?-?( T *, ptrdiff_t ); 207 206 forall( dtype T | sized(T) ) const T * ?-?( const T *, ptrdiff_t ); 208 forall( dtype T | sized(T) ) volatile T * 207 forall( dtype T | sized(T) ) volatile T * ?-?( volatile T *, ptrdiff_t ); 209 208 forall( dtype T | sized(T) ) const volatile T * ?-?( const volatile T *, ptrdiff_t ); 210 209 forall( dtype T | sized(T) ) ptrdiff_t ?-?( const volatile T *, const volatile T * ); … … 232 231 signed int ?<?( _Bool, _Bool ), ?<=?( _Bool, _Bool ), 233 232 ?>?( _Bool, _Bool ), ?>=?( _Bool, _Bool ); 234 signed int ?<?( char, char ), ?<=?( char, char ),235 ?>?( char, char ), ?>=?( char, char );233 signed int ?<?( char, char ), ?<=?( char, char ), 234 ?>?( char, char ), ?>=?( char, char ); 236 235 signed int ?<?( signed char, signed char ), ?<=?( signed char, signed char ), 237 236 ?>?( signed char, signed char ), ?>=?( signed char, signed char ); … … 241 240 ?>?( signed short, signed short ), ?>=?( signed short, signed short ); 242 241 signed int ?<?( unsigned short, unsigned short ), ?<=?( unsigned short, unsigned short ), 243 ?>?( unsigned short, unsigned short ), 242 ?>?( unsigned short, unsigned short ), ?>=?( unsigned short, unsigned short ); 244 243 signed int ?<?( signed int, signed int ), ?<=?( signed int, signed int ), 245 244 ?>?( signed int, signed int ), ?>=?( signed int, signed int ); … … 474 473 forall( ftype FT ) FT * ?=?( FT * volatile &, zero_t ); 475 474 476 forall( dtype T | sized(T) ) T * 477 forall( dtype T | sized(T) ) T * 475 forall( dtype T | sized(T) ) T * ?+=?( T * &, ptrdiff_t ); 476 forall( dtype T | sized(T) ) T * ?+=?( T * volatile &, ptrdiff_t ); 478 477 forall( dtype T | sized(T) ) const T * ?+=?( const T * &, ptrdiff_t ); 479 478 forall( dtype T | sized(T) ) const T * ?+=?( const T * volatile &, ptrdiff_t ); 480 forall( dtype T | sized(T) ) volatile T * 481 forall( dtype T | sized(T) ) volatile T * 479 forall( dtype T | sized(T) ) volatile T * ?+=?( volatile T * &, ptrdiff_t ); 480 forall( dtype T | sized(T) ) volatile T * ?+=?( volatile T * volatile &, ptrdiff_t ); 482 481 forall( dtype T | sized(T) ) const volatile T * ?+=?( const volatile T * &, ptrdiff_t ); 483 482 forall( dtype T | sized(T) ) const volatile T * ?+=?( const volatile T * volatile &, ptrdiff_t ); 484 forall( dtype T | sized(T) ) T * 485 forall( dtype T | sized(T) ) T * 483 forall( dtype T | sized(T) ) T * ?-=?( T * &, ptrdiff_t ); 484 forall( dtype T | sized(T) ) T * ?-=?( T * volatile &, ptrdiff_t ); 486 485 forall( dtype T | sized(T) ) const T * ?-=?( const T * &, ptrdiff_t ); 487 486 forall( dtype T | sized(T) ) const T * ?-=?( const T * volatile &, ptrdiff_t ); 488 forall( dtype T | sized(T) ) volatile T * 489 forall( dtype T | sized(T) ) volatile T * 487 forall( dtype T | sized(T) ) volatile T * ?-=?( volatile T * &, ptrdiff_t ); 488 forall( dtype T | sized(T) ) volatile T * ?-=?( volatile T * volatile &, ptrdiff_t ); 490 489 forall( dtype T | sized(T) ) const volatile T * ?-=?( const volatile T * &, ptrdiff_t ); 491 490 forall( dtype T | sized(T) ) const volatile T * ?-=?( const volatile T * volatile &, ptrdiff_t ); … … 503 502 signed long long int ?=?( signed long long int &, signed long long int ), ?=?( volatile signed long long int &, signed long long int ); 504 503 unsigned long long int ?=?( unsigned long long int &, unsigned long long int ), ?=?( volatile unsigned long long int &, unsigned long long int ); 505 zero_t ?=?( zero_t &, zero_t );504 zero_t ?=?( zero_t &, zero_t ); 506 505 one_t ?=?( one_t &, one_t ); 507 506 … … 674 673 ?+=?( long double _Complex &, long double _Complex ), ?+=?( volatile long double _Complex &, long double _Complex ), 675 674 ?-=?( long double _Complex &, long double _Complex ), ?-=?( volatile long double _Complex &, long double _Complex ); 676 677 678 679 675 680 676 … … 846 842 forall( dtype DT ) void ^?{}( const volatile DT * &); 847 843 848 void 849 void 850 void 851 void ^?{}( constvolatile void * &);844 void ^?{}( void * &); 845 void ^?{}( const void * &); 846 void ^?{}( volatile void * &); 847 void ^?{}( const volatile void * &); 852 848 853 849 // Local Variables: // -
src/tests/boundedBuffer.c
r85d340d rb1e68d03 1 // 2 // The contents of this file are covered under the licence agreement in the 3 // file "LICENCE" distributed with Cforall. 4 // 5 // boundedBuffer.c -- 6 // 7 // Author : Peter A. Buhr 8 // Created On : Mon Oct 30 12:45:13 2017 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Mon Oct 30 23:02:46 2017 11 // Update Count : 9 12 // 13 1 14 #include <stdlib> 2 #include <fstream> 15 #include <fstream> // random 3 16 #include <kernel> 4 17 #include <thread> 5 #include <unistd.h> // getpid18 #include <unistd.h> // getpid 6 19 7 20 monitor Buffer { 8 9 10 21 condition full, empty; 22 int front, back, count; 23 int elements[20]; 11 24 }; 12 25 13 26 void ?{}( Buffer & buffer ) { 14 27 buffer.front = buffer.back = buffer.count = 0; 15 28 } 16 29 … … 18 31 19 32 void insert( Buffer & mutex buffer, int elem ) { 20 21 22 23 24 33 if ( buffer.count == 20 ) wait( &buffer.empty ); 34 buffer.elements[buffer.back] = elem; 35 buffer.back = ( buffer.back + 1 ) % 20; 36 buffer.count += 1; 37 signal( &buffer.full ); 25 38 } 26 39 int remove( Buffer & mutex buffer ) { 27 28 29 30 31 32 40 if ( buffer.count == 0 ) wait( &buffer.full ); 41 int elem = buffer.elements[buffer.front]; 42 buffer.front = ( buffer.front + 1 ) % 20; 43 buffer.count -= 1; 44 signal( &buffer.empty ); 45 return elem; 33 46 } 34 47 35 48 thread Producer { 36 Buffer *buffer;37 49 Buffer & buffer; 50 unsigned int N; 38 51 }; 39 52 void main( Producer & prod ) { 40 41 yield( (unsigned int)rand48() % 5);42 insert( *prod.buffer, 1 );43 44 insert( *prod.buffer, -1 );53 for ( int i = 1; i <= prod.N; i += 1 ) { 54 yield( random( 5 ) ); 55 insert( prod.buffer, 1 ); 56 } // for 57 insert( prod.buffer, -1 ); 45 58 } 46 59 void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) { 47 48 49 }60 &prod.buffer = buffer; 61 prod.N = N; 62 } 50 63 51 64 thread Consumer { 52 Buffer *buffer;53 int *sum; // summation of producer values65 Buffer & buffer; 66 int & sum; // summation of producer values 54 67 }; 55 68 void main( Consumer & cons ) { 56 *cons.sum = 0;57 58 yield( (unsigned int)rand48() % 5);59 int item = remove( *cons.buffer );60 61 *cons.sum += item;62 69 cons.sum = 0; 70 for ( ;; ) { 71 yield( random( 5 ) ); 72 int item = remove( cons.buffer ); 73 if ( item == -1 ) break; // sentinel ? 74 cons.sum += item; 75 } // for 63 76 } 64 77 void ?{}( Consumer & cons, Buffer * buffer, int * sum ) { 65 66 78 &cons.buffer = buffer; 79 &cons.sum = sum; 67 80 } 68 81 69 82 int main() { 70 71 72 73 74 75 76 77 83 Buffer buffer; 84 enum { Prods = 5, Cons = 5 }; 85 Producer * prods[Prods]; 86 Consumer * cons[Cons]; 87 const int Sentinel = -1; 88 int sums[Cons]; 89 int i; 90 processor p; 78 91 79 //rand48seed( getpid() );80 rand48seed( 1003 );92 //random_seed( getpid() ); 93 random_seed( 1003 ); 81 94 82 83 cons[i] = new( &buffer, &sums[i] );84 85 86 prods[i] = new( &buffer, 100000u );87 95 for ( i = 0; i < Cons; i += 1 ) { // create consumers 96 cons[i] = new( &buffer, &sums[i] ); 97 } // for 98 for ( i = 0; i < Prods; i += 1 ) { // create producers 99 prods[i] = new( &buffer, 100000u ); 100 } // for 88 101 89 90 delete( prods[i] );91 92 93 insert( buffer, Sentinel );94 95 96 97 delete( cons[i] );98 sum += sums[i];99 100 102 for ( i = 0; i < Prods; i += 1 ) { // wait for producers to finish 103 delete( prods[i] ); 104 } // for 105 for ( i = 0; i < Cons; i += 1 ) { // generate sentinal values to stop consumers 106 insert( buffer, Sentinel ); 107 } // for 108 int sum = 0; 109 for ( i = 0; i < Cons; i += 1 ) { // wait for consumers to finish 110 delete( cons[i] ); 111 sum += sums[i]; 112 } // for 113 sout | "total:" | sum | endl; 101 114 } 115 116 // Local Variables: // 117 // tab-width: 4 // 118 // compile-command: "cfa boundedBuffer.c" // 119 // End: // -
src/tests/matrixSum.c
r85d340d rb1e68d03 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Mon Oct 9 08:30:08 201714 // Update Count : 113 // Last Modified On : Sun Oct 29 21:08:48 2017 14 // Update Count : 2 15 15 // 16 16 … … 20 20 21 21 thread Adder { 22 int * row, cols, * subtotal; // communication22 int * row, cols, * subtotal; // communication 23 23 }; 24 24 … … 32 32 *adder.subtotal = 0; 33 33 for ( int c = 0; c < adder.cols; c += 1 ) { 34 *adder.subtotal += adder.row[c];34 *adder.subtotal += adder.row[c]; 35 35 } // for 36 36 } … … 39 39 const int rows = 10, cols = 1000; 40 40 int matrix[rows][cols], subtotals[rows], total = 0; 41 processor p; // extra kernel thread41 processor p; // extra kernel thread 42 42 43 43 for ( int r = 0; r < rows; r += 1 ) { 44 for ( int c = 0; c < cols; c += 1 ) {45 46 } // for44 for ( int c = 0; c < cols; c += 1 ) { 45 matrix[r][c] = 1; 46 } // for 47 47 } // for 48 48 Adder * adders[rows]; 49 for ( int r = 0; r < rows; r += 1 ) { // start threads to sum rows50 adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };51 // adders[r] = new( matrix[r], cols, &subtotals[r] );49 for ( int r = 0; r < rows; r += 1 ) { // start threads to sum rows 50 adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] }; 51 // adders[r] = new( matrix[r], cols, &subtotals[r] ); 52 52 } // for 53 for ( int r = 0; r < rows; r += 1 ) { // wait for threads to finish54 delete( adders[r] );55 total += subtotals[r];// total subtotals53 for ( int r = 0; r < rows; r += 1 ) { // wait for threads to finish 54 delete( adders[r] ); 55 total += subtotals[r]; // total subtotals 56 56 } // for 57 57 sout | total | endl; -
src/tests/prodcons.c
r85d340d rb1e68d03 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Sep 20 17:03:28201713 // Update Count : 4 012 // Last Modified On : Mon Oct 30 23:06:05 2017 13 // Update Count : 42 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <coroutine> 18 #include <stdlib> // rand 4818 #include <stdlib> // random 19 19 #include <unistd.h> // getpid 20 20 … … 30 30 // 1st resume starts here 31 31 for ( int i = 0; i < prod.N; i += 1 ) { 32 int p1 = (unsigned int)rand48() % 100; // non-negative33 int p2 = (unsigned int)rand48() % 100;32 int p1 = random( 100 ); 33 int p2 = random( 100 ); 34 34 sout | p1 | " " | p2 | endl; 35 35 int status = delivery( *prod.c, p1, p2 ); … … 90 90 Prod prod; 91 91 Cons cons = { prod }; 92 rand 48seed( /* getpid() */ 103 ); // fixed seed for testing92 random_seed( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 94 sout | "main stops" | endl; -
src/tests/random.c
r85d340d rb1e68d03 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 6 18:00:29 201613 // Update Count : 312 // Last Modified On : Mon Oct 30 23:06:49 2017 13 // Update Count : 6 14 14 // 15 15 … … 19 19 20 20 int main() { 21 // rand48seed( getpid() ); // set random seed22 rand 48seed( 1003 );// fixed seed for repeatable tests21 //srandom( getpid() ); // set random seed 22 random_seed( 1003 ); // fixed seed for repeatable tests 23 23 24 24 // test polymorphic calls to random and stream 25 char c = rand 48();25 char c = random(); 26 26 sout | c | endl; 27 int i = rand 48();27 int i = random(); 28 28 sout | i | endl; 29 unsigned int ui = rand 48();29 unsigned int ui = random(); 30 30 sout | ui | endl; 31 long int li = rand 48();31 long int li = random(); 32 32 sout | li | endl; 33 unsigned long int uli = rand 48();33 unsigned long int uli = random(); 34 34 sout | uli | endl; 35 float f = rand 48();35 float f = random(); 36 36 sout | f | endl; 37 double d = rand 48();37 double d = random(); 38 38 sout | d | endl; 39 float _Complex fc = rand 48();39 float _Complex fc = random(); 40 40 sout | fc | endl; 41 double _Complex dc = rand 48();41 double _Complex dc = random(); 42 42 sout | dc | endl; 43 long double _Complex ldc = rand 48();43 long double _Complex ldc = random(); 44 44 sout | ldc | endl; 45 45 } // main -
src/tests/rational.c
r85d340d rb1e68d03 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:40:11201713 // Update Count : 6 612 // Last Modified On : Tue Oct 10 23:25:04 2017 13 // Update Count : 67 14 14 // 15 15 -
src/tests/sched-ext-barge.c
r85d340d rb1e68d03 42 42 void main( barger_t & this ) { 43 43 yield(); 44 while( barge( global ) ) { yield( ((unsigned)rand48()) % 10); }44 while( barge( global ) ) { yield(random( 10 )); } 45 45 } 46 46 47 47 bool do_call( global_t & mutex this ) { 48 yield( ((unsigned)rand48()) % 10);48 yield(random( 10 )); 49 49 if( this.state != WAITFOR && !this.done && this.started ) { 50 50 serr | "Barging before caller detected" | endl; … … 57 57 thread caller_t {}; 58 58 void main( caller_t & this ) { 59 while( do_call(global) ) { yield( ((unsigned)rand48()) % 10); }59 while( do_call(global) ) { yield(random( 10 )); } 60 60 } 61 61 … … 63 63 this.started = true; 64 64 for( int i = 0; i < N; i++) { 65 yield( ((unsigned)rand48()) % 10);65 yield(random( 10 )); 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { -
src/tests/sched-ext-dtor.c
r85d340d rb1e68d03 45 45 46 46 void main( dummy_t & this ) { 47 yield( ((unsigned)rand48()) % 10);47 yield(random( 10 )); 48 48 set_state( this, MAIN ); 49 49 waitfor( ^?{}, this ) { … … 58 58 for( int i = 0; i < N; i++ ){ 59 59 dummy_t dummy[4]; 60 yield( ((unsigned)rand48()) % 100);60 yield( random( 100 ) ); 61 61 } 62 62 sout | "Stopping" | endl; -
src/tests/sched-ext-recurse.c
r85d340d rb1e68d03 15 15 static const unsigned long N = 5_000ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 enum state_t { FIRST, SECOND, THIRD, LAST, STOP }; … … 23 23 for (i = 0; i < 4; i++) 24 24 { 25 int j = ((unsigned)rand48()) % 4;25 int j = random( 4 ); 26 26 enum state_t t = array[j]; 27 27 array[j] = array[i]; … … 131 131 132 132 int main() { 133 rand 48seed( time(NULL) );133 random_seed( time(NULL) ); 134 134 sout | "Starting" | endl; 135 135 { -
src/tests/sched-ext-when.c
r85d340d rb1e68d03 15 15 static const unsigned long N = 4_998ul; 16 16 17 static inline void rand_yield() { yield( ((unsigned)rand48()) % 10); }17 static inline void rand_yield() { yield(random( 10 )); } 18 18 19 19 monitor global_t { … … 77 77 78 78 int main() { 79 rand 48seed( time(NULL) );79 random_seed( time(NULL) ); 80 80 sout | "Starting" | endl; 81 81 { -
src/tests/sched-ext.c
r85d340d rb1e68d03 26 26 volatile bool done; 27 27 28 unsigned rand10() {29 return (unsigned)rand48() % 10;30 }31 32 28 //---------------------------------------------------------------------------------------------------- 33 29 // Acceptor … … 36 32 void do_wait( global_t * mutex a ) { 37 33 sout | "Waiting to accept" | endl; 38 yield( rand 10() );34 yield( random( 10 ) ); 39 35 40 36 sout | "Accepting" | endl; … … 48 44 49 45 sout | "Accepted" | endl; 50 yield( rand 10() );46 yield( random( 10 ) ); 51 47 } 52 48 … … 68 64 void main( Acceptee* this ) { 69 65 while( !done ) { 70 yield( rand 10() );66 yield( random( 10 ) ); 71 67 do_notify( &globalA ); 72 yield( rand 10() );68 yield( random( 10 ) ); 73 69 } 74 70 } … … 78 74 int main(int argc, char* argv[]) { 79 75 done = false; 80 rand 48seed( time( NULL ) );76 random_seed( time( NULL ) ); 81 77 printf("%p\n", &globalA); 82 78 sout | "Starting" | endl; -
src/tests/sched-int-barge.c
r85d340d rb1e68d03 64 64 65 65 if( action == 0 ) { 66 c.do_signal = max( ((unsigned)rand48()) % 10, 1);67 c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);68 c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);66 c.do_signal = max( random( 10 ), 1); 67 c.do_wait1 = random( c.do_signal ); 68 c.do_wait2 = random( c.do_signal ); 69 69 70 70 if(c.do_wait1 == c.do_wait2) sout | "Same" | endl; … … 109 109 110 110 int main(int argc, char* argv[]) { 111 rand 48seed(0);111 random_seed(0); 112 112 processor p; 113 113 { -
src/tests/sched-int-block.c
r85d340d rb1e68d03 49 49 wait( &cond, (uintptr_t)this_thread ); 50 50 51 yield( ((unsigned)rand48()) % 10);51 yield( random( 10 ) ); 52 52 53 53 if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) { … … 58 58 a.last_thread = b.last_thread = this_thread; 59 59 60 yield( ((unsigned)rand48()) % 10);60 yield( random( 10 ) ); 61 61 } 62 62 … … 70 70 //------------------------------------------------------------------------------ 71 71 void signal_op( global_data_t & mutex a, global_data_t & mutex b ) { 72 yield( ((unsigned)rand48()) % 10);72 yield( random( 10 ) ); 73 73 74 74 [a.last_thread, b.last_thread, a.last_signaller, b.last_signaller] = this_thread; … … 83 83 } 84 84 85 yield( ((unsigned)rand48()) % 10);85 yield( random( 10 ) ); 86 86 87 87 if(a.last_thread != next || b.last_thread != next) { … … 118 118 119 119 int main(int argc, char* argv[]) { 120 rand 48seed( time( NULL ) );120 random_seed( time( NULL ) ); 121 121 done = false; 122 122 processor p; -
src/tests/sched-int-disjoint.c
r85d340d rb1e68d03 88 88 signal( &cond, a, data ); 89 89 90 yield( (unsigned)rand48() % 10);90 yield( random( 10 ) ); 91 91 92 92 //This is technically a mutual exclusion violation but the mutex monitor protects us … … 109 109 // Main loop 110 110 int main(int argc, char* argv[]) { 111 rand 48seed( time( NULL ) );111 random_seed( time( NULL ) ); 112 112 all_done = false; 113 113 processor p; -
src/tests/sched-int-wait.c
r85d340d rb1e68d03 62 62 63 63 while( waiter_left != 0 ) { 64 unsigned action = (unsigned)rand48() % 4;64 unsigned action = random( 4 ); 65 65 switch( action ) { 66 66 case 0: … … 127 127 // Main 128 128 int main(int argc, char* argv[]) { 129 rand 48seed( time( NULL ) );129 random_seed( time( NULL ) ); 130 130 waiter_left = 4; 131 131 processor p[2];
Note: See TracChangeset
for help on using the changeset viewer.