Changes in / [4f748c5:fde89cf6]
- Files:
-
- 11 added
- 35 deleted
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r4f748c5 rfde89cf6 52 52 tools/prettyprinter/pretty 53 53 tools/pretty 54 tools/catchsig55 tools/repeat56 54 57 55 # generated by xfig for user manual -
configure
r4f748c5 rfde89cf6 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/ 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/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" ;;7051 7050 "tools/prettyprinter/Makefile") CONFIG_FILES="$CONFIG_FILES tools/prettyprinter/Makefile" ;; 7052 7051 -
configure.ac
r4f748c5 rfde89cf6 238 238 src/prelude/Makefile 239 239 src/libcfa/Makefile 240 tools/Makefile241 240 tools/prettyprinter/Makefile 242 241 ]) -
src/Parser/lex.ll
r4f748c5 rfde89cf6 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Oct 25 13:53:56201713 * Update Count : 63 412 * Last Modified On : Sat Sep 23 17:29:28 2017 13 * Update Count : 632 14 14 */ 15 15 … … 233 233 __extension__ { KEYWORD_RETURN(EXTENSION); } // GCC 234 234 extern { KEYWORD_RETURN(EXTERN); } 235 fallthrough { KEYWORD_RETURN(FALLTHRU); } // CFA 235 236 fallthru { KEYWORD_RETURN(FALLTHRU); } // CFA 236 fallthrough { KEYWORD_RETURN(FALLTHROUGH); } // CFA237 237 finally { KEYWORD_RETURN(FINALLY); } // CFA 238 238 float { KEYWORD_RETURN(FLOAT); } -
src/Parser/parser.yy
r4f748c5 rfde89cf6 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Oct 25 12:28:54201713 // Update Count : 289 312 // Last Modified On : Mon Oct 16 11:07:29 2017 13 // Update Count : 2892 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 FALLTHROUGHTRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH WHEN WAITFOR // CFA182 %token CHOOSE DISABLE ENABLE FALLTHRU 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 // support location tracking for error messages364 %locations 365 365 366 366 %start translation_unit // parse-tree root … … 974 974 ; 975 975 976 fall_through _name:// CFA976 fall_through: // CFA 977 977 FALLTHRU 978 | FALLTHROUGH979 ;980 981 fall_through: // CFA982 fall_through_name983 978 { $$ = nullptr; } 984 | fall_through_name';'979 | FALLTHRU ';' 985 980 { $$ = nullptr; } 986 981 ; … … 2491 2486 | TYPEDEFname 2492 2487 | TYPEGENname 2493 | FALLTHROUGH2494 { $$ = Token{ new string( "fallthrough" ), { nullptr, -1 } }; }2495 2488 | CONST 2496 2489 { $$ = Token{ new string( "__const__" ), { nullptr, -1 } }; } … … 2758 2751 // 2759 2752 // typedef int foo; 2760 // forall( otype T ) struct foo;2753 // forall( otype T ) foo( T ); 2761 2754 // int f( int foo ); // redefine typedef name in new scope 2762 2755 // -
src/benchmark/Makefile.am
r4f748c5 rfde89cf6 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}repeat23 STATS = ${TOOLSDIR}stat.py24 repeats = 3025 21 26 .NOTPARALLEL: 27 28 noinst_PROGRAMS = 22 noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT) 29 23 30 24 bench$(EXEEXT) : … … 36 30 rm -f ./a.out ; 37 31 32 ctxswitch-coroutine$(EXEEXT): 33 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 CorCtxSwitch.c 34 @rm -f .result.log 35 @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 done 38 @./stat.py .result.log 39 @rm -f a.out .result.log 40 41 ctxswitch-thread$(EXEEXT): 42 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 ThrdCtxSwitch.c 43 @rm -f .result.log 44 @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 done 47 @./stat.py .result.log 48 @rm -f a.out .result.log 49 50 ctxswitch-pthread$(EXEEXT): 51 @BACKEND_CC@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} -lrt -pthread -DN=50000000 PthrdCtxSwitch.c 52 @rm -f .result.log 53 @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 done 56 @./stat.py .result.log 57 @rm -f a.out .result.log 58 59 sched-int$(EXEEXT): 60 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 SchedInt.c 61 @rm -f .result.log 62 @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 done 65 @./stat.py .result.log 66 @rm -f a.out .result.log 67 68 monitor$(EXEEXT): 69 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 Monitor.c 70 @rm -f .result.log 71 @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 done 74 @./stat.py .result.log 75 @rm -f a.out .result.log 76 38 77 csv-data$(EXEEXT): 39 78 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=50000000 csv-data.c 40 79 @./a.out 41 80 @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.run50 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.run73 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.run97 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.run122 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.run141 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.log158 @echo "------------------------------------------------------"159 @echo $<160 @${REPEAT} ${repeats} ./a.out | tee -a .result.log161 @${STATS} .result.log162 @echo "------------------------------------------------------"163 @rm -f a.out .result.log164 165 ${REPEAT} :166 @+make -C ${TOOLSDIR} repeat -
src/benchmark/Makefile.in
r4f748c5 rfde89cf6 92 92 build_triplet = @build@ 93 93 host_triplet = @host@ 94 noinst_PROGRAMS =95 94 subdir = src/benchmark 96 95 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 … … 104 103 CONFIG_CLEAN_VPATH_FILES = 105 104 PROGRAMS = $(noinst_PROGRAMS) 105 bench_SOURCES = bench.c 106 bench_OBJECTS = bench.$(OBJEXT) 107 bench_LDADD = $(LDADD) 108 csv_data_SOURCES = csv-data.c 109 csv_data_OBJECTS = csv-data.$(OBJEXT) 110 csv_data_LDADD = $(LDADD) 111 ctxswitch_coroutine_SOURCES = ctxswitch-coroutine.c 112 ctxswitch_coroutine_OBJECTS = ctxswitch-coroutine.$(OBJEXT) 113 ctxswitch_coroutine_LDADD = $(LDADD) 114 ctxswitch_thread_SOURCES = ctxswitch-thread.c 115 ctxswitch_thread_OBJECTS = ctxswitch-thread.$(OBJEXT) 116 ctxswitch_thread_LDADD = $(LDADD) 117 monitor_SOURCES = monitor.c 118 monitor_OBJECTS = monitor.$(OBJEXT) 119 monitor_LDADD = $(LDADD) 120 sched_int_SOURCES = sched-int.c 121 sched_int_OBJECTS = sched-int.$(OBJEXT) 122 sched_int_LDADD = $(LDADD) 106 123 AM_V_P = $(am__v_P_@AM_V@) 107 124 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) … … 116 133 am__v_at_0 = @ 117 134 am__v_at_1 = 118 SOURCES = 119 DIST_SOURCES = 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 120 155 am__can_run_installinfo = \ 121 156 case $$AM_UPDATE_INFO_DIR in \ … … 124 159 esac 125 160 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 126 am__DIST_COMMON = $(srcdir)/Makefile.in 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 127 180 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 128 181 ACLOCAL = @ACLOCAL@ … … 249 302 top_srcdir = @top_srcdir@ 250 303 AM_CFLAGS = -g -Wall -Wno-unused-function -O2 251 TOOLSDIR = ${abs_top_srcdir}/tools/ 252 REPEAT = ${TOOLSDIR}repeat 253 STATS = ${TOOLSDIR}stat.py 254 repeats = 30 304 noinst_PROGRAMS = bench$(EXEEXT) ctxswitch-coroutine$(EXEEXT) ctxswitch-thread$(EXEEXT) sched-int$(EXEEXT) monitor$(EXEEXT) csv-data$(EXEEXT) 255 305 all: all-am 256 306 257 307 .SUFFIXES: 308 .SUFFIXES: .c .o .obj 258 309 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) 259 310 @for dep in $?; do \ … … 288 339 clean-noinstPROGRAMS: 289 340 -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) 290 tags TAGS: 291 292 ctags CTAGS: 293 294 cscope cscopelist: 295 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 296 422 297 423 distdir: $(DISTFILES) … … 364 490 365 491 distclean: distclean-am 492 -rm -rf ./$(DEPDIR) 366 493 -rm -f Makefile 367 distclean-am: clean-am distclean-generic 494 distclean-am: clean-am distclean-compile distclean-generic \ 495 distclean-tags 368 496 369 497 dvi: dvi-am … … 408 536 409 537 maintainer-clean: maintainer-clean-am 538 -rm -rf ./$(DEPDIR) 410 539 -rm -f Makefile 411 540 maintainer-clean-am: distclean-am maintainer-clean-generic … … 413 542 mostlyclean: mostlyclean-am 414 543 415 mostlyclean-am: mostlyclean- generic544 mostlyclean-am: mostlyclean-compile mostlyclean-generic 416 545 417 546 pdf: pdf-am … … 427 556 .MAKE: install-am install-strip 428 557 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 \ 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 \ 439 569 uninstall-am 440 570 441 571 .PRECIOUS: Makefile 442 572 443 444 .NOTPARALLEL:445 573 446 574 bench$(EXEEXT) : … … 452 580 rm -f ./a.out ; 453 581 582 ctxswitch-coroutine$(EXEEXT): 583 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 CorCtxSwitch.c 584 @rm -f .result.log 585 @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 done 588 @./stat.py .result.log 589 @rm -f a.out .result.log 590 591 ctxswitch-thread$(EXEEXT): 592 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 ThrdCtxSwitch.c 593 @rm -f .result.log 594 @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 done 597 @./stat.py .result.log 598 @rm -f a.out .result.log 599 600 ctxswitch-pthread$(EXEEXT): 601 @BACKEND_CC@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} -lrt -pthread -DN=50000000 PthrdCtxSwitch.c 602 @rm -f .result.log 603 @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 done 606 @./stat.py .result.log 607 @rm -f a.out .result.log 608 609 sched-int$(EXEEXT): 610 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 SchedInt.c 611 @rm -f .result.log 612 @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 done 615 @./stat.py .result.log 616 @rm -f a.out .result.log 617 618 monitor$(EXEEXT): 619 ${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -DN=50000000 Monitor.c 620 @rm -f .result.log 621 @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 done 624 @./stat.py .result.log 625 @rm -f a.out .result.log 626 454 627 csv-data$(EXEEXT): 455 628 @${CC} ${AM_CFLAGS} ${CFLAGS} ${ccflags} @CFA_FLAGS@ -nodebug -lrt -quiet -DN=50000000 csv-data.c … … 457 630 @rm -f ./a.out 458 631 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.run465 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.run487 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.run510 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.run534 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.run552 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.log567 @echo "------------------------------------------------------"568 @echo $<569 @${REPEAT} ${repeats} ./a.out | tee -a .result.log570 @${STATS} .result.log571 @echo "------------------------------------------------------"572 @rm -f a.out .result.log573 574 ${REPEAT} :575 @+make -C ${TOOLSDIR} repeat576 577 632 # Tell versions [3.59,3.63) of GNU make to not export all variables. 578 633 # Otherwise a system limit (for SysV at least) may be exceeded. -
src/benchmark/bench.h
r4f748c5 rfde89cf6 1 1 #pragma once 2 2 3 #if defined(__CFORALL__)3 #ifdef __CFORALL__ 4 4 extern "C" { 5 5 #endif 6 #include <stdlib.h>7 6 #include <unistd.h> // sysconf 8 7 #include <sys/times.h> // times 9 8 #include <time.h> 10 #if defined(__CFORALL__)9 #ifdef __CFORALL__ 11 10 } 12 11 #endif … … 28 27 } // Time 29 28 30 #ifndef BENCH_N31 #define BENCH_N 500 //1000000029 #ifndef N 30 #define N 10000000 32 31 #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;46 32 47 33 unsigned int default_preemption() { -
src/driver/cfa.cc
r4f748c5 rfde89cf6 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 31 11:40:44201713 // Update Count : 1 6012 // Last Modified On : Tue Sep 26 23:12:38 2017 13 // Update Count : 159 14 14 // 15 15 … … 305 305 } // if 306 306 307 shuffle( args, sargs, nargs, 1 ); // make room at front of argument list308 nargs += 1;309 307 if ( CFA_flag ) { 310 args[sargs] = "-D__CFA_FLAG__=-N";311 308 args[nargs] = "-D__CFA_PREPROCESS_"; 312 309 nargs += 1; 313 } else { 314 args[sargs] = "-D__CFA_FLAG__=-L"; 315 } // if 316 sargs += 1; 310 } // if 317 311 318 312 if ( debug ) { -
src/libcfa/concurrency/kernel.c
r4f748c5 rfde89cf6 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( abort_text, len );550 __lib_debug_write( STDERR_FILENO, 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( abort_text, len );554 __lib_debug_write( STDERR_FILENO, abort_text, len ); 555 555 } 556 556 else { 557 __lib_debug_write( ".\n", 2 );557 __lib_debug_write( STDERR_FILENO, ".\n", 2 ); 558 558 } 559 559 } -
src/libcfa/concurrency/monitor.c
r4f748c5 rfde89cf6 21 21 #include "kernel_private.h" 22 22 23 #include "bits/algorithms.h"24 25 23 //----------------------------------------------------------------------------- 26 24 // Forward declarations … … 97 95 else if( this->owner == thrd) { 98 96 // We already have the monitor, just note how many times we took it 97 verify( this->recursion > 0 ); 99 98 this->recursion += 1; 100 99 … … 208 207 // it means we don't need to do anything 209 208 if( this->recursion != 0) { 210 LIB_DEBUG_PRINT_SAFE("Kernel : recursion still %d\n", this->recursion);211 209 unlock( &this->lock ); 212 210 return; … … 293 291 294 292 // Sort monitors based on address -> TODO use a sort specialized for small numbers 295 __libcfa_small_sort(this.m, count);293 qsort(this.m, count); 296 294 297 295 // Save previous thread context … … 494 492 set_owner( monitors, count, signallee ); 495 493 496 LIB_DEBUG_PRINT_BUFFER_DECL( "Kernel : signal_block condition %p (s: %p)\n", this, signallee );497 498 494 //Everything is ready to go to sleep 499 495 BlockInternal( locks, count, &signallee, 1 ); … … 502 498 // WE WOKE UP 503 499 504 505 LIB_DEBUG_PRINT_BUFFER_LOCAL( "Kernel : signal_block returned\n" );506 500 507 501 //We are back, restore the masks and recursions … … 542 536 short actual_count = aggregate( mon_storage, mask ); 543 537 544 LIB_DEBUG_PRINT_ BUFFER_DECL("Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max);538 LIB_DEBUG_PRINT_SAFE("Kernel : waitfor %d (s: %d, m: %d)\n", actual_count, mask.size, (short)max); 545 539 546 540 if(actual_count == 0) return; 547 541 548 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : waitfor internal proceeding\n");542 LIB_DEBUG_PRINT_SAFE("Kernel : waitfor internal proceeding\n"); 549 543 550 544 // Create storage for monitor context … … 562 556 *mask.accepted = index; 563 557 if( mask.clauses[index].is_dtor ) { 564 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : dtor already there\n");558 LIB_DEBUG_PRINT_SAFE("Kernel : dtor already there\n"); 565 559 verifyf( mask.clauses[index].size == 1 , "ERROR: Accepted dtor has more than 1 mutex parameter." ); 566 560 … … 574 568 } 575 569 else { 576 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : thread present, baton-passing\n");570 LIB_DEBUG_PRINT_SAFE("Kernel : thread present, baton-passing\n"); 577 571 578 572 // Create the node specific to this wait operation … … 582 576 monitor_save; 583 577 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 #endif590 LIB_DEBUG_PRINT_BUFFER_LOCAL( "\n");591 592 578 // Set the owners to be the next thread 593 579 set_owner( monitors, count, next ); … … 599 585 monitor_restore; 600 586 601 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : thread present, returned\n");587 LIB_DEBUG_PRINT_SAFE("Kernel : thread present, returned\n"); 602 588 } 603 589 604 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : accepted %d\n", *mask.accepted);590 LIB_DEBUG_PRINT_SAFE("Kernel : accepted %d\n", *mask.accepted); 605 591 606 592 return; … … 610 596 611 597 if( duration == 0 ) { 612 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : non-blocking, exiting\n");598 LIB_DEBUG_PRINT_SAFE("Kernel : non-blocking, exiting\n"); 613 599 614 600 unlock_all( locks, count ); 615 601 616 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : accepted %d\n", *mask.accepted);602 LIB_DEBUG_PRINT_SAFE("Kernel : accepted %d\n", *mask.accepted); 617 603 return; 618 604 } … … 621 607 verifyf( duration < 0, "Timeout on waitfor statments not supported yet."); 622 608 623 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : blocking waitfor\n");609 LIB_DEBUG_PRINT_SAFE("Kernel : blocking waitfor\n"); 624 610 625 611 // Create the node specific to this wait operation … … 643 629 monitor_restore; 644 630 645 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : exiting\n");646 647 LIB_DEBUG_PRINT_ BUFFER_LOCAL("Kernel : accepted %d\n", *mask.accepted);631 LIB_DEBUG_PRINT_SAFE("Kernel : exiting\n"); 632 633 LIB_DEBUG_PRINT_SAFE("Kernel : accepted %d\n", *mask.accepted); 648 634 } 649 635 … … 662 648 663 649 static inline void set_owner( monitor_desc ** monitors, short count, thread_desc * 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; 650 for( int i = 0; i < count; i++ ) { 651 set_owner( monitors[i], owner ); 669 652 } 670 653 } … … 684 667 static inline thread_desc * next_thread( monitor_desc * this ) { 685 668 //Check the signaller stack 686 LIB_DEBUG_PRINT_SAFE("Kernel : mon %p AS-stack top %p\n", this, this->signal_stack.top);687 669 __condition_criterion_t * urgent = pop( &this->signal_stack ); 688 670 if( urgent ) { … … 736 718 for(int i = 0; i < count; i++) { 737 719 (criteria[i]){ monitors[i], waiter }; 738 LIB_DEBUG_PRINT_SAFE( "Kernel : target %p = %p\n", criteria[i].target, &criteria[i] );739 720 push( &criteria[i].target->signal_stack, &criteria[i] ); 740 721 } … … 807 788 } 808 789 809 LIB_DEBUG_PRINT_SAFE( "Kernel : Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL);790 // LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run ); 810 791 return ready2run ? node->waiting_thread : NULL; 811 792 } … … 875 856 short size = 0; 876 857 for( int i = 0; i < mask.size; i++ ) { 877 __libcfa_small_sort( mask.clauses[i].list, mask.clauses[i].size );878 858 for( int j = 0; j < mask.clauses[i].size; j++) { 879 859 insert_unique( storage, size, mask.clauses[i].list[j] ); 880 860 } 881 861 } 882 // TODO insertion sort instead of this 883 __libcfa_small_sort( storage, size ); 862 qsort( storage, size ); 884 863 return size; 885 864 } -
src/libcfa/concurrency/preemption.c
r4f748c5 rfde89cf6 380 380 381 381 if ( sigaction( sig, &act, NULL ) == -1 ) { 382 LIB_DEBUG_PRINT_BUFFER_DECL( 382 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, 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( 399 LIB_DEBUG_PRINT_BUFFER_DECL( STDERR_FILENO, 400 400 " __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 401 401 sig, errno, strerror( errno ) -
src/libcfa/interpose.c
r4f748c5 rfde89cf6 127 127 va_end( args ); 128 128 129 __lib_debug_write( abort_text, len );130 __lib_debug_write( "\n", 1 );129 __lib_debug_write( STDERR_FILENO, abort_text, len ); 130 __lib_debug_write( STDERR_FILENO, "\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( abort_text, len );134 __lib_debug_write( STDERR_FILENO, abort_text, len ); 135 135 136 136 -
src/libcfa/libhdr/libdebug.c
r4f748c5 rfde89cf6 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( const char *in_buffer, int len ) {30 void __lib_debug_write( int fd, 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( STDERR_FILENO, in_buffer, len - count );36 retcode = write( fd, 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( buffer, len );56 __lib_debug_write( STDERR_FILENO, 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( buffer, len );68 __lib_debug_write( STDERR_FILENO, 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( buffer, len );75 __lib_debug_write( STDERR_FILENO, 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( in_buffer, len );84 __lib_debug_write( STDERR_FILENO, in_buffer, len ); 85 85 86 86 va_end( args ); -
src/libcfa/libhdr/libdebug.h
r4f748c5 rfde89cf6 44 44 extern "C" { 45 45 #endif 46 #include <stdarg.h> 47 #include <stdio.h> 46 #include <stdarg.h> 48 47 49 extern void __lib_debug_write( const char *buffer, int len );48 extern void __lib_debug_write( int fd, const char *buffer, int len ); 50 49 extern void __lib_debug_acquire(); 51 50 extern void __lib_debug_release(); … … 59 58 60 59 #ifdef __CFA_DEBUG_PRINT__ 61 #define LIB_DEBUG_WRITE( buffer, len ) __lib_debug_write(buffer, len )60 #define LIB_DEBUG_WRITE( fd, buffer, len ) __lib_debug_write( fd, buffer, len ) 62 61 #define LIB_DEBUG_ACQUIRE() __lib_debug_acquire() 63 62 #define LIB_DEBUG_RELEASE() __lib_debug_release() … … 65 64 #define LIB_DEBUG_PRINT_NOLOCK(...) __lib_debug_print_nolock (__VA_ARGS__) 66 65 #define LIB_DEBUG_PRINT_BUFFER(...) __lib_debug_print_buffer (__VA_ARGS__) 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 );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 ); 69 68 #else 70 69 #define LIB_DEBUG_WRITE(...) ((void)0) -
src/libcfa/stdlib
r4f748c5 rfde89cf6 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 31 13:47:24201713 // Update Count : 2 4512 // Last Modified On : Wed Aug 23 20:29:47 2017 13 // Update Count : 224 14 14 // 15 15 … … 27 27 // allocation, non-array types 28 28 static inline forall( dtype T | sized(T) ) T * malloc( void ) { 29 // printf( "* malloc\n" );29 //printf( "X1\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 malloc35 // printf( "& malloc %p\n", &p );36 // return p;37 // // return (T &)*(T *)(void *)malloc( (size_t)sizeof(T) ); // C malloc38 // } // malloc39 32 40 33 extern "C" { void * calloc( size_t dim, size_t size ); } // default C routine … … 213 206 //--------------------------------------- 214 207 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 ); 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 ); 231 219 232 220 //--------------------------------------- -
src/libcfa/stdlib.c
r4f748c5 rfde89cf6 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 22:43:02201713 // Update Count : 29 712 // Last Modified On : Wed Aug 23 20:30:44 2017 13 // Update Count : 292 14 14 // 15 15 … … 275 275 //--------------------------------------- 276 276 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); } 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); } 293 288 294 289 //--------------------------------------- -
src/main.cc
r4f748c5 rfde89cf6 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Peter A. Buhr13 // Last Modified On : Tue Oct 31 12:22:40 201714 // Update Count : 44 512 // Last Modified By : Andrew Beach 13 // Last Modified On : Wed Jul 26 14:38:00 2017 14 // Update Count : 443 15 15 // 16 16 … … 81 81 expraltp = false, 82 82 libcfap = false, 83 preludep = false,84 83 nopreludep = false, 85 84 noprotop = false, … … 379 378 380 379 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 381 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Preamble,Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };380 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, }; 382 381 383 382 static struct option long_opts[] = { … … 391 390 { "grammar", no_argument, 0, Grammar }, 392 391 { "libcfa", no_argument, 0, LibCFA }, 393 { "preamble", no_argument, 0, Preamble },394 392 { "no-preamble", no_argument, 0, Nopreamble }, 395 393 { "parse", no_argument, 0, Parse }, … … 407 405 408 406 int c; 409 while ( (c = getopt_long( argc, argv, "abBcCdefglLmn NpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) {407 while ( (c = getopt_long( argc, argv, "abBcCdefglLmnpqrstTvyzZD:F:", long_opts, &long_index )) != -1 ) { 410 408 switch ( c ) { 411 409 case Ast: … … 453 451 case 'n': // do not read preamble 454 452 nopreludep = true; 455 break;456 case Preamble:457 case 'N': // read preamble458 preludep = true;459 453 break; 460 454 case Prototypes: -
src/prelude/prelude.cf
r4f748c5 rfde89cf6 7 7 // Created On : Sat Nov 29 07:23:41 2014 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : S at Oct 28 16:33:09201710 // Update Count : 1029 // Last Modified On : Sun Oct 8 12:21:33 2017 10 // Update Count : 97 11 11 // 12 12 … … 41 41 _Bool ?++( _Bool & ), ?++( volatile _Bool & ); 42 42 _Bool ?--( _Bool & ), ?--( volatile _Bool & ); 43 unsigned char ?++( unsigned char & ), ?++( volatile unsigned char & ); 43 44 signed short ?++( signed short & ), ?++( volatile signed short & ); 44 45 signed short ?--( signed short & ), ?--( volatile signed short & ); … … 195 196 long double _Complex ?+?( long double _Complex, long double _Complex ), ?-?( long double _Complex, long double _Complex ); 196 197 197 forall( dtype T | sized(T) ) T * ?+?( T *, ptrdiff_t );198 forall( dtype T | sized(T) ) T * ?+?( ptrdiff_t, T * );198 forall( dtype T | sized(T) ) T * ?+?( T *, ptrdiff_t ); 199 forall( dtype T | sized(T) ) T * ?+?( ptrdiff_t, T * ); 199 200 forall( dtype T | sized(T) ) const T * ?+?( const T *, ptrdiff_t ); 200 201 forall( dtype T | sized(T) ) const T * ?+?( ptrdiff_t, const 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 * );202 forall( dtype T | sized(T) ) volatile T * ?+?( volatile T *, ptrdiff_t ); 203 forall( dtype T | sized(T) ) volatile T * ?+?( ptrdiff_t, volatile T * ); 203 204 forall( dtype T | sized(T) ) const volatile T * ?+?( const volatile T *, ptrdiff_t ); 204 205 forall( dtype T | sized(T) ) const volatile T * ?+?( ptrdiff_t, const volatile T * ); 205 forall( dtype T | sized(T) ) T * ?-?( T *, ptrdiff_t );206 forall( dtype T | sized(T) ) T * ?-?( T *, ptrdiff_t ); 206 207 forall( dtype T | sized(T) ) const T * ?-?( const T *, ptrdiff_t ); 207 forall( dtype T | sized(T) ) volatile T * ?-?( volatile T *, ptrdiff_t );208 forall( dtype T | sized(T) ) volatile T * ?-?( volatile T *, ptrdiff_t ); 208 209 forall( dtype T | sized(T) ) const volatile T * ?-?( const volatile T *, ptrdiff_t ); 209 210 forall( dtype T | sized(T) ) ptrdiff_t ?-?( const volatile T *, const volatile T * ); … … 231 232 signed int ?<?( _Bool, _Bool ), ?<=?( _Bool, _Bool ), 232 233 ?>?( _Bool, _Bool ), ?>=?( _Bool, _Bool ); 233 signed int ?<?( char, char ), 234 ?>?( char, char ), 234 signed int ?<?( char, char ), ?<=?( char, char ), 235 ?>?( char, char ), ?>=?( char, char ); 235 236 signed int ?<?( signed char, signed char ), ?<=?( signed char, signed char ), 236 237 ?>?( signed char, signed char ), ?>=?( signed char, signed char ); … … 240 241 ?>?( signed short, signed short ), ?>=?( signed short, signed short ); 241 242 signed int ?<?( unsigned short, unsigned short ), ?<=?( unsigned short, unsigned short ), 242 ?>?( unsigned short, unsigned short ), ?>=?( unsigned short, unsigned short );243 ?>?( unsigned short, unsigned short ), ?>=?( unsigned short, unsigned short ); 243 244 signed int ?<?( signed int, signed int ), ?<=?( signed int, signed int ), 244 245 ?>?( signed int, signed int ), ?>=?( signed int, signed int ); … … 473 474 forall( ftype FT ) FT * ?=?( FT * volatile &, zero_t ); 474 475 475 forall( dtype T | sized(T) ) T * ?+=?( T * &, ptrdiff_t );476 forall( dtype T | sized(T) ) T * ?+=?( T * volatile &, ptrdiff_t );476 forall( dtype T | sized(T) ) T * ?+=?( T * &, ptrdiff_t ); 477 forall( dtype T | sized(T) ) T * ?+=?( T * volatile &, ptrdiff_t ); 477 478 forall( dtype T | sized(T) ) const T * ?+=?( const T * &, ptrdiff_t ); 478 479 forall( dtype T | sized(T) ) const T * ?+=?( const T * volatile &, ptrdiff_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 );480 forall( dtype T | sized(T) ) volatile T * ?+=?( volatile T * &, ptrdiff_t ); 481 forall( dtype T | sized(T) ) volatile T * ?+=?( volatile T * volatile &, ptrdiff_t ); 481 482 forall( dtype T | sized(T) ) const volatile T * ?+=?( const volatile T * &, ptrdiff_t ); 482 483 forall( dtype T | sized(T) ) const volatile T * ?+=?( const volatile T * volatile &, ptrdiff_t ); 483 forall( dtype T | sized(T) ) T * ?-=?( T * &, ptrdiff_t );484 forall( dtype T | sized(T) ) T * ?-=?( T * volatile &, ptrdiff_t );484 forall( dtype T | sized(T) ) T * ?-=?( T * &, ptrdiff_t ); 485 forall( dtype T | sized(T) ) T * ?-=?( T * volatile &, ptrdiff_t ); 485 486 forall( dtype T | sized(T) ) const T * ?-=?( const T * &, ptrdiff_t ); 486 487 forall( dtype T | sized(T) ) const T * ?-=?( const T * volatile &, ptrdiff_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 );488 forall( dtype T | sized(T) ) volatile T * ?-=?( volatile T * &, ptrdiff_t ); 489 forall( dtype T | sized(T) ) volatile T * ?-=?( volatile T * volatile &, ptrdiff_t ); 489 490 forall( dtype T | sized(T) ) const volatile T * ?-=?( const volatile T * &, ptrdiff_t ); 490 491 forall( dtype T | sized(T) ) const volatile T * ?-=?( const volatile T * volatile &, ptrdiff_t ); … … 502 503 signed long long int ?=?( signed long long int &, signed long long int ), ?=?( volatile signed long long int &, signed long long int ); 503 504 unsigned long long int ?=?( unsigned long long int &, unsigned long long int ), ?=?( volatile unsigned long long int &, unsigned long long int ); 504 zero_t 505 zero_t ?=?( zero_t &, zero_t ); 505 506 one_t ?=?( one_t &, one_t ); 506 507 … … 673 674 ?+=?( long double _Complex &, long double _Complex ), ?+=?( volatile long double _Complex &, long double _Complex ), 674 675 ?-=?( long double _Complex &, long double _Complex ), ?-=?( volatile long double _Complex &, long double _Complex ); 676 677 678 675 679 676 680 … … 842 846 forall( dtype DT ) void ^?{}( const volatile DT * &); 843 847 844 void ^?{}( void * &);845 void ^?{}( const void * &);846 void ^?{}( volatile void * &);847 void ^?{}( constvolatile void * &);848 void ^?{}( void * &); 849 void ^?{}( const void * &); 850 void ^?{}( volatile void * &); 851 void ^?{}( const volatile void * &); 848 852 849 853 // Local Variables: // -
src/tests/boundedBuffer.c
r4f748c5 rfde89cf6 1 //2 // The contents of this file are covered under the licence agreement in the3 // file "LICENCE" distributed with Cforall.4 //5 // boundedBuffer.c --6 //7 // Author : Peter A. Buhr8 // Created On : Mon Oct 30 12:45:13 20179 // Last Modified By : Peter A. Buhr10 // Last Modified On : Mon Oct 30 23:02:46 201711 // Update Count : 912 //13 14 1 #include <stdlib> 15 #include <fstream> // random2 #include <fstream> 16 3 #include <kernel> 17 4 #include <thread> 18 #include <unistd.h> 5 #include <unistd.h> // getpid 19 6 20 7 monitor Buffer { 21 22 23 8 condition full, empty; 9 int front, back, count; 10 int elements[20]; 24 11 }; 25 12 26 13 void ?{}( Buffer & buffer ) { 27 14 buffer.front = buffer.back = buffer.count = 0; 28 15 } 29 16 … … 31 18 32 19 void insert( Buffer & mutex buffer, int elem ) { 33 34 35 36 37 20 if ( buffer.count == 20 ) wait( &buffer.empty ); 21 buffer.elements[buffer.back] = elem; 22 buffer.back = ( buffer.back + 1 ) % 20; 23 buffer.count += 1; 24 signal( &buffer.full ); 38 25 } 39 26 int remove( Buffer & mutex buffer ) { 40 41 42 43 44 45 27 if ( buffer.count == 0 ) wait( &buffer.full ); 28 int elem = buffer.elements[buffer.front]; 29 buffer.front = ( buffer.front + 1 ) % 20; 30 buffer.count -= 1; 31 signal( &buffer.empty ); 32 return elem; 46 33 } 47 34 48 35 thread Producer { 49 Buffer &buffer;50 36 Buffer * buffer; 37 unsigned int N; 51 38 }; 52 39 void main( Producer & prod ) { 53 54 yield( random( 5 ));55 insert(prod.buffer, 1 );56 57 insert(prod.buffer, -1 );40 for ( int i = 1; i <= prod.N; i += 1 ) { 41 yield( (unsigned int)rand48() % 5 ); 42 insert( *prod.buffer, 1 ); 43 } // for 44 insert( *prod.buffer, -1 ); 58 45 } 59 46 void ?{}( Producer & prod, Buffer * buffer, unsigned int N ) { 60 &prod.buffer = buffer;61 62 47 prod.buffer = buffer; 48 prod.N = N; 49 } 63 50 64 51 thread Consumer { 65 Buffer &buffer;66 int ∑ // summation of producer values52 Buffer * buffer; 53 int * sum; // summation of producer values 67 54 }; 68 55 void main( Consumer & cons ) { 69 70 71 yield( random( 5 ));72 int item = remove(cons.buffer );73 74 75 56 *cons.sum = 0; 57 for ( ;; ) { 58 yield( (unsigned int)rand48() % 5 ); 59 int item = remove( *cons.buffer ); 60 if ( item == -1 ) break; // sentinel ? 61 *cons.sum += item; 62 } // for 76 63 } 77 64 void ?{}( Consumer & cons, Buffer * buffer, int * sum ) { 78 &cons.buffer = buffer;79 &cons.sum = sum;65 cons.buffer = buffer; 66 cons.sum = sum; 80 67 } 81 68 82 69 int main() { 83 84 85 86 87 88 89 90 70 Buffer buffer; 71 enum { Prods = 5, Cons = 5 }; 72 Producer * prods[Prods]; 73 Consumer * cons[Cons]; 74 const int Sentinel = -1; 75 int sums[Cons]; 76 int i; 77 processor p; 91 78 92 //random_seed( getpid() );93 random_seed( 1003 );79 //rand48seed( getpid() ); 80 rand48seed( 1003 ); 94 81 95 96 97 98 99 100 82 for ( i = 0; i < Cons; i += 1 ) { // create consumers 83 cons[i] = new( &buffer, &sums[i] ); 84 } // for 85 for ( i = 0; i < Prods; i += 1 ) { // create producers 86 prods[i] = new( &buffer, 100000u ); 87 } // for 101 88 102 103 104 105 106 107 108 109 110 111 112 113 89 for ( i = 0; i < Prods; i += 1 ) { // wait for producers to finish 90 delete( prods[i] ); 91 } // for 92 for ( i = 0; i < Cons; i += 1 ) { // generate sentinal values to stop consumers 93 insert( buffer, Sentinel ); 94 } // for 95 int sum = 0; 96 for ( i = 0; i < Cons; i += 1 ) { // wait for consumers to finish 97 delete( cons[i] ); 98 sum += sums[i]; 99 } // for 100 sout | "total:" | sum | endl; 114 101 } 115 116 // Local Variables: //117 // tab-width: 4 //118 // compile-command: "cfa boundedBuffer.c" //119 // End: // -
src/tests/matrixSum.c
r4f748c5 rfde89cf6 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Sun Oct 29 21:08:48 201714 // Update Count : 213 // Last Modified On : Mon Oct 9 08:30:08 2017 14 // Update Count : 1 15 15 // 16 16 … … 20 20 21 21 thread Adder { 22 int * row, cols, * subtotal; 22 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 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; 41 processor p; // extra kernel thread 42 42 43 43 for ( int r = 0; r < rows; r += 1 ) { 44 45 46 44 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 ) { 50 51 // 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 ) { 54 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
r4f748c5 rfde89cf6 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 23:06:05201713 // Update Count : 4 212 // Last Modified On : Wed Sep 20 17:03:28 2017 13 // Update Count : 40 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <coroutine> 18 #include <stdlib> // rand om18 #include <stdlib> // rand48 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 = random( 100 );33 int p2 = random( 100 );32 int p1 = (unsigned int)rand48() % 100; // non-negative 33 int p2 = (unsigned int)rand48() % 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 om_seed( /* getpid() */ 103 ); // fixed seed for testing92 rand48seed( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 94 sout | "main stops" | endl; -
src/tests/random.c
r4f748c5 rfde89cf6 10 10 // Created On : Tue Jul 5 21:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Oct 30 23:06:49 201713 // Update Count : 612 // Last Modified On : Wed Jul 6 18:00:29 2016 13 // Update Count : 3 14 14 // 15 15 … … 19 19 20 20 int main() { 21 // srandom( getpid() ); // set random seed22 rand om_seed( 1003 );// fixed seed for repeatable tests21 //rand48seed( getpid() ); // set random seed 22 rand48seed( 1003 ); // fixed seed for repeatable tests 23 23 24 24 // test polymorphic calls to random and stream 25 char c = rand om();25 char c = rand48(); 26 26 sout | c | endl; 27 int i = rand om();27 int i = rand48(); 28 28 sout | i | endl; 29 unsigned int ui = rand om();29 unsigned int ui = rand48(); 30 30 sout | ui | endl; 31 long int li = rand om();31 long int li = rand48(); 32 32 sout | li | endl; 33 unsigned long int uli = rand om();33 unsigned long int uli = rand48(); 34 34 sout | uli | endl; 35 float f = rand om();35 float f = rand48(); 36 36 sout | f | endl; 37 double d = rand om();37 double d = rand48(); 38 38 sout | d | endl; 39 float _Complex fc = rand om();39 float _Complex fc = rand48(); 40 40 sout | fc | endl; 41 double _Complex dc = rand om();41 double _Complex dc = rand48(); 42 42 sout | dc | endl; 43 long double _Complex ldc = rand om();43 long double _Complex ldc = rand48(); 44 44 sout | ldc | endl; 45 45 } // main -
src/tests/rational.c
r4f748c5 rfde89cf6 10 10 // Created On : Mon Mar 28 08:43:12 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Oct 10 23:25:04201713 // Update Count : 6 712 // Last Modified On : Wed Aug 23 21:40:11 2017 13 // Update Count : 66 14 14 // 15 15 -
src/tests/sched-ext-barge.c
r4f748c5 rfde89cf6 42 42 void main( barger_t & this ) { 43 43 yield(); 44 while( barge( global ) ) { yield( random( 10 )); }44 while( barge( global ) ) { yield(((unsigned)rand48()) % 10); } 45 45 } 46 46 47 47 bool do_call( global_t & mutex this ) { 48 yield( random( 10 ));48 yield(((unsigned)rand48()) % 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( random( 10 )); }59 while( do_call(global) ) { yield(((unsigned)rand48()) % 10); } 60 60 } 61 61 … … 63 63 this.started = true; 64 64 for( int i = 0; i < N; i++) { 65 yield( random( 10 ));65 yield(((unsigned)rand48()) % 10); 66 66 this.state = WAITFOR; 67 67 waitfor(do_call, this) { -
src/tests/sched-ext-dtor.c
r4f748c5 rfde89cf6 45 45 46 46 void main( dummy_t & this ) { 47 yield( random( 10 ));47 yield(((unsigned)rand48()) % 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( random( 100 ));60 yield( ((unsigned)rand48()) % 100 ); 61 61 } 62 62 sout | "Stopping" | endl; -
src/tests/sched-ext-recurse.c
r4f748c5 rfde89cf6 15 15 static const unsigned long N = 5_000ul; 16 16 17 static inline void rand_yield() { yield( random( 10 )); }17 static inline void rand_yield() { yield(((unsigned)rand48()) % 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 = random( 4 );25 int j = ((unsigned)rand48()) % 4; 26 26 enum state_t t = array[j]; 27 27 array[j] = array[i]; … … 131 131 132 132 int main() { 133 rand om_seed( time(NULL) );133 rand48seed( time(NULL) ); 134 134 sout | "Starting" | endl; 135 135 { -
src/tests/sched-ext-when.c
r4f748c5 rfde89cf6 15 15 static const unsigned long N = 4_998ul; 16 16 17 static inline void rand_yield() { yield( random( 10 )); }17 static inline void rand_yield() { yield(((unsigned)rand48()) % 10); } 18 18 19 19 monitor global_t { … … 77 77 78 78 int main() { 79 rand om_seed( time(NULL) );79 rand48seed( time(NULL) ); 80 80 sout | "Starting" | endl; 81 81 { -
src/tests/sched-ext.c
r4f748c5 rfde89cf6 26 26 volatile bool done; 27 27 28 unsigned rand10() { 29 return (unsigned)rand48() % 10; 30 } 31 28 32 //---------------------------------------------------------------------------------------------------- 29 33 // Acceptor … … 32 36 void do_wait( global_t * mutex a ) { 33 37 sout | "Waiting to accept" | endl; 34 yield( rand om( 10) );38 yield( rand10() ); 35 39 36 40 sout | "Accepting" | endl; … … 44 48 45 49 sout | "Accepted" | endl; 46 yield( rand om( 10) );50 yield( rand10() ); 47 51 } 48 52 … … 64 68 void main( Acceptee* this ) { 65 69 while( !done ) { 66 yield( rand om( 10) );70 yield( rand10() ); 67 71 do_notify( &globalA ); 68 yield( rand om( 10) );72 yield( rand10() ); 69 73 } 70 74 } … … 74 78 int main(int argc, char* argv[]) { 75 79 done = false; 76 rand om_seed( time( NULL ) );80 rand48seed( time( NULL ) ); 77 81 printf("%p\n", &globalA); 78 82 sout | "Starting" | endl; -
src/tests/sched-int-barge.c
r4f748c5 rfde89cf6 64 64 65 65 if( action == 0 ) { 66 c.do_signal = max( random( 10 ), 1);67 c.do_wait1 = random( c.do_signal);68 c.do_wait2 = random( c.do_signal);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); 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 om_seed(0);111 rand48seed(0); 112 112 processor p; 113 113 { -
src/tests/sched-int-block.c
r4f748c5 rfde89cf6 49 49 wait( &cond, (uintptr_t)this_thread ); 50 50 51 yield( random( 10 ));51 yield( ((unsigned)rand48()) % 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( random( 10 ));60 yield( ((unsigned)rand48()) % 10 ); 61 61 } 62 62 … … 70 70 //------------------------------------------------------------------------------ 71 71 void signal_op( global_data_t & mutex a, global_data_t & mutex b ) { 72 yield( random( 10 ));72 yield( ((unsigned)rand48()) % 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( random( 10 ));85 yield( ((unsigned)rand48()) % 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 om_seed( time( NULL ) );120 rand48seed( time( NULL ) ); 121 121 done = false; 122 122 processor p; -
src/tests/sched-int-disjoint.c
r4f748c5 rfde89cf6 88 88 signal( &cond, a, data ); 89 89 90 yield( random( 10 ));90 yield( (unsigned)rand48() % 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 om_seed( time( NULL ) );111 rand48seed( time( NULL ) ); 112 112 all_done = false; 113 113 processor p; -
src/tests/sched-int-wait.c
r4f748c5 rfde89cf6 62 62 63 63 while( waiter_left != 0 ) { 64 unsigned action = random( 4 );64 unsigned action = (unsigned)rand48() % 4; 65 65 switch( action ) { 66 66 case 0: … … 127 127 // Main 128 128 int main(int argc, char* argv[]) { 129 rand om_seed( time( NULL ) );129 rand48seed( time( NULL ) ); 130 130 waiter_left = 4; 131 131 processor p[2];
Note:
See TracChangeset
for help on using the changeset viewer.