Changeset 2ab67b9
- Timestamp:
- May 30, 2017, 7:49:45 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f3fc631f
- Parents:
- 8f61052c (diff), 4a368547 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 8 added
- 5 deleted
- 8 edited
- 8 moved
Legend:
- Unmodified
- Added
- Removed
-
Jenkinsfile
r8f61052c r2ab67b9 28 28 wrap([$class: 'TimestamperBuildWrapper']) { 29 29 30 notify_server( 1)30 notify_server(0) 31 31 32 32 prepare_build() 33 33 34 34 checkout() 35 36 notify_server(0) 35 37 36 38 build() -
doc/LaTeXmacros/lstlang.sty
r8f61052c r2ab67b9 107 107 \lstdefinelanguage{CFA}[ANSI]{C}{ 108 108 morekeywords={ 109 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, _ Atomic, __attribute,109 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute, 110 110 __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, 111 __const, __const__, coroutine, disable, dtype, enable, __extension__, fallthrough, fallthru, 112 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, monitor, mutex, 113 _Noreturn, one_t, otype, restrict, _Static_assert, thread, _Thread_local, throw, throwResume, 114 trait, try, ttype, typeof, __typeof, __typeof__, zero_t}, 111 __const, __const__, disable, dtype, enable, __extension__, fallthrough, fallthru, 112 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t, 113 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof, 114 __typeof__, zero_t}, 115 morekeywords=[2]{ 116 accept, _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex, 117 resume, signal, signal_block, suspend, thread, _Thread_local, wait, yield}, 115 118 } 116 119 -
doc/proposals/concurrency/.gitignore
r8f61052c r2ab67b9 1 concurrency.aux 2 concurrency.acn 3 concurrency.acr 4 concurrency.alg 5 concurrency.bbl 6 concurrency.blg 7 concurrency.brf 8 concurrency.dvi 9 concurrency.glg 10 concurrency.glo 11 concurrency.gls 12 concurrency.idx 13 concurrency.ind 14 concurrency.ist 15 concurrency.log 16 concurrency.out 17 concurrency.pdf 18 concurrency.ps 19 version.aux 20 monitor.tex 21 ext_monitor.tex 1 build/*.aux 2 build/*.acn 3 build/*.acr 4 build/*.alg 5 build/*.bbl 6 build/*.blg 7 build/*.brf 8 build/*.dvi 9 build/*.glg 10 build/*.glo 11 build/*.gls 12 build/*.idx 13 build/*.ind 14 build/*.ist 15 build/*.log 16 build/*.out 17 build/*.ps 18 build/*.tex 19 build/*.toc 20 *.pdf 21 22 examples -
doc/proposals/concurrency/Makefile
r8f61052c r2ab67b9 1 1 ## Define the appropriate configuration variables. 2 2 3 TeXLIB = .:. ./../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies:4 LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error 5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex 3 TeXLIB = .:./style:./text:./annex:./build:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies: 4 LaTeX = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=build -interaction=nonstopmode 5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex -terse 6 6 7 7 ## Define the text source files. 8 8 9 9 SOURCES = ${addsuffix .tex, \ 10 concurrency \ 11 style \ 12 cfa-format \ 13 glossary \ 10 thesis \ 11 style/style \ 12 style/cfa-format \ 13 annex/glossary \ 14 text/intro \ 15 text/basics \ 16 text/concurrency \ 17 text/parallelism \ 14 18 } 15 19 16 FIGURES = ${add suffix .tex, \20 FIGURES = ${addprefix build/, ${addsuffix .tex, \ 17 21 monitor \ 18 22 ext_monitor \ 19 } 23 }} 20 24 21 25 PICTURES = ${addsuffix .pstex, \ … … 30 34 ## Define the documents that need to be made. 31 35 32 DOCUMENT = concurrency.pdf36 DOCUMENT = thesis.pdf 33 37 34 38 # Directives # … … 37 41 38 42 clean : 39 rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf *.glg *.glo *.gls *.ist *.acn *.acr *.alg \ 40 ${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT} 43 @rm -fv ${DOCUMENT} \ 44 build/*.acn \ 45 build/*.acr \ 46 build/*.alg \ 47 build/*.aux \ 48 build/*.bbl \ 49 build/*.blg \ 50 build/*.brf \ 51 build/*.cf \ 52 build/*.dvi \ 53 build/*.glg \ 54 build/*.glo \ 55 build/*.gls \ 56 build/*.ist \ 57 build/*.idx \ 58 build/*.ilg \ 59 build/*.ind \ 60 build/*.log \ 61 build/*.out \ 62 build/*.ps \ 63 build/*.pstex_t \ 64 build/*.tex \ 65 build/*.toc \ 66 41 67 42 68 # File Dependencies # 43 69 44 ${DOCUMENT} : ${basename ${DOCUMENT}}.ps70 ${DOCUMENT} : build/${basename ${DOCUMENT}}.ps 45 71 ps2pdf $< 46 72 47 ${basename ${DOCUMENT}}.ps :${basename ${DOCUMENT}}.dvi73 build/${basename ${DOCUMENT}}.ps : build/${basename ${DOCUMENT}}.dvi 48 74 dvips $< -o $@ 49 75 50 ${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \ 51 ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle 52 # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 53 if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi 54 # Must have *.aux file containing citations for bibtex 55 if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi 56 -${BibTeX} ${basename $@} 57 # Some citations reference others so run steps again to resolve these citations 58 ${LaTeX} ${basename $@}.tex 59 -${BibTeX} ${basename $@} 60 # Make index from *.aux entries and input index at end of document 61 makeglossaries ${basename $@} 62 #${LaTeX} ${basename $@}.tex 63 # Run again to get index title into table of contents 64 ${LaTeX} ${basename $@}.tex 65 -./bump_ver.sh 66 ${LaTeX} ${basename $@}.tex 76 build/${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle 77 78 @ if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run. 79 @ echo "Citation lookup" # Must have *.aux file containing citations for bibtex 80 @ if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename ${notdir $@}}.tex ; fi 81 @ echo "Citation Pass 1" 82 @ -${BibTeX} ${basename $@} # Some citations reference others so run steps again to resolve these citations 83 @ echo "Citation Pass 2" 84 @ ${LaTeX} ${basename ${notdir $@}}.tex 85 @ -${BibTeX} ${basename $@} 86 @ echo "Glossary" 87 makeglossaries -q -s ${basename $@}.ist ${basename $@} # Make index from *.aux entries and input index at end of document 88 @ echo ".dvi generation" 89 @ -build/bump_ver.sh 90 @ ${LaTeX} ${basename ${notdir $@}}.tex # Run again to get index title into table of contents 67 91 68 92 … … 72 96 ## Define the default recipes. 73 97 74 %.tex :%.fig98 build/%.tex : figures/%.fig 75 99 fig2dev -L eepic $< > $@ 76 100 77 %.ps :%.fig101 build/%.ps : figures/%.fig 78 102 fig2dev -L ps $< > $@ 79 103 80 %.pstex :%.fig104 build/%.pstex : figures/%.fig 81 105 fig2dev -L pstex $< > $@ 82 106 fig2dev -L pstex_t -p $@ $< > $@_t -
doc/proposals/concurrency/style/cfa-format.tex
r8f61052c r2ab67b9 1 \usepackage {xcolor}1 \usepackage[usenames,dvipsnames]{xcolor} 2 2 \usepackage{listings} 3 3 \usepackage{inconsolata} … … 144 144 % moredelim=** allows cumulative application 145 145 } 146 \lstset{ 147 morekeywords=[2]{nomutex,mutex,thread,wait,wait_release,signal,signal_block,accept,monitor,suspend,resume,coroutine} 148 language = CFA, 149 style=defaultStyle 150 } 146 151 147 \lstMakeShortInline[basewidth=0.5em,breaklines=true,basicstyle=\normalsize\ttfamily\color{basicCol}]@ % single-character for \lstinline 152 148 153 \lstnewenvironment{cfacode}[1][]{ % 154 \lstset{ % 155 language = CFA, % 156 style=defaultStyle, % 157 morekeywords=[2]{nomutex,mutex,thread,wait,signal,signal_block,accept,monitor,suspend,resume,coroutine}, % 158 #1 % 159 } % 149 \lstnewenvironment{ccode}[1][]{ 150 \lstset{ 151 language = C, 152 style=defaultStyle, 153 #1 154 } 155 }{} 156 157 \lstnewenvironment{cfacode}[1][]{ 158 \lstset{ 159 language = CFA, 160 style=defaultStyle, 161 #1 162 } 160 163 }{} 161 164 … … 169 172 170 173 \lstnewenvironment{cppcode}[1][]{ 174 \lstset{ 175 language = c++, 176 style=defaultStyle, 177 #1 178 } 179 }{} 180 181 \lstnewenvironment{ucppcode}[1][]{ 171 182 \lstset{ 172 183 language = c++, … … 219 230 \newcommand{\one}{\lstinline{one_t}\xspace} 220 231 \newcommand{\ateq}{\lstinline{\@=}\xspace} 232 \newcommand{\code}[1]{\lstinline[language=CFA,style=defaultStyle]{#1}} 233 \newcommand{\pscode}[1]{\lstinline[language=pseudo,style=pseudoStyle]{#1}} -
src/libcfa/concurrency/monitor
r8f61052c r2ab67b9 59 59 unsigned short count; //Number of criterions in the criteria 60 60 __condition_node_t * next; //Intrusive linked list Next field 61 uintptr_t user_info; //Custom user info accessible before signalling 61 62 }; 62 63 … … 85 86 } 86 87 87 void wait( condition * this ); 88 void signal( condition * this ); 89 void signal_block( condition * this ); 88 void wait( condition * this, uintptr_t user_info = 0 ); 89 bool signal( condition * this ); 90 bool signal_block( condition * this ); 91 static inline bool is_empty( condition * this ) { return !this->blocked.head; } 92 uintptr_t front( condition * this ); 93 90 94 #endif //MONITOR_H -
src/libcfa/concurrency/monitor.c
r8f61052c r2ab67b9 137 137 } 138 138 139 void debug_break() __attribute__(( noinline )) 140 { 141 139 void ?{}(__condition_node_t * this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) { 140 this->waiting_thread = waiting_thread; 141 this->count = count; 142 this->next = NULL; 143 this->user_info = user_info; 144 } 145 146 void ?{}(__condition_criterion_t * this ) { 147 this->ready = false; 148 this->target = NULL; 149 this->owner = NULL; 150 this->next = NULL; 151 } 152 153 void ?{}(__condition_criterion_t * this, monitor_desc * target, __condition_node_t * owner ) { 154 this->ready = false; 155 this->target = target; 156 this->owner = owner; 157 this->next = NULL; 142 158 } 143 159 144 160 //----------------------------------------------------------------------------- 145 161 // Internal scheduling 146 void wait( condition * this ) {162 void wait( condition * this, uintptr_t user_info = 0 ) { 147 163 LIB_DEBUG_PRINT_SAFE("Waiting\n"); 148 164 … … 160 176 LIB_DEBUG_PRINT_SAFE("count %i\n", count); 161 177 162 __condition_node_t waiter; 163 waiter.waiting_thread = this_thread(); 164 waiter.count = count; 165 waiter.next = NULL; 178 __condition_node_t waiter = { this_thread(), count, user_info }; 166 179 167 180 __condition_criterion_t criteria[count]; 168 181 for(int i = 0; i < count; i++) { 169 criteria[i].ready = false; 170 criteria[i].target = this->monitors[i]; 171 criteria[i].owner = &waiter; 172 criteria[i].next = NULL; 182 (&criteria[i]){ this->monitors[i], &waiter }; 173 183 LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] ); 174 184 } … … 202 212 ScheduleInternal( locks, count, threads, thread_count ); 203 213 204 debug_break();205 214 //WE WOKE UP 206 215 … … 212 221 } 213 222 214 voidsignal( condition * this ) {215 if( !this->blocked.head) {223 bool signal( condition * this ) { 224 if( is_empty( this ) ) { 216 225 LIB_DEBUG_PRINT_SAFE("Nothing to signal\n"); 217 return ;226 return false; 218 227 } 219 228 … … 257 266 //Release 258 267 unlock_all( this->monitors, count ); 259 } 260 261 void signal_block( condition * this ) { 268 269 return true; 270 } 271 272 bool signal_block( condition * this ) { 262 273 if( !this->blocked.head ) { 263 274 LIB_DEBUG_PRINT_SAFE("Nothing to signal\n"); 264 return ;275 return false; 265 276 } 266 277 … … 276 287 277 288 //create creteria 278 __condition_node_t waiter; 279 waiter.waiting_thread = this_thread(); 280 waiter.count = count; 281 waiter.next = NULL; 289 __condition_node_t waiter = { this_thread(), count, 0 }; 282 290 283 291 __condition_criterion_t criteria[count]; 284 292 for(int i = 0; i < count; i++) { 293 (&criteria[i]){ this->monitors[i], &waiter }; 285 294 LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] ); 286 criteria[i].ready = false;287 criteria[i].owner = &waiter;288 criteria[i].next = NULL;289 criteria[i].target = this->monitors[i];290 295 push( &criteria[i].target->signal_stack, &criteria[i] ); 291 296 } … … 303 308 304 309 LIB_DEBUG_PRINT_SAFE( "Waiting on signal block\n" ); 305 debug_break();306 310 307 311 //Everything is ready to go to sleep 308 312 ScheduleInternal( locks, count, &signallee, 1 ); 309 313 310 debug_break();311 314 LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" ); 312 315 … … 315 318 restore_recursion( this->monitors, recursions, count ); 316 319 unlock_all( locks, count ); 320 321 return true; 322 } 323 324 uintptr_t front( condition * this ) { 325 LIB_DEBUG_DO( 326 if( is_empty(this) ) { 327 abortf( "Attempt to access user data on an empty condition.\n" 328 "Possible cause is not checking if the condition is empty before reading stored data." ); 329 } 330 ); 331 return this->blocked.head->user_info; 317 332 } 318 333 -
src/tests/sched-int-block.c
r8f61052c r2ab67b9 10 10 11 11 monitor global_data_t { 12 state_t state;13 bool ran;12 thread_desc * last_thread; 13 thread_desc * last_signaller; 14 14 }; 15 15 16 16 void ?{} ( global_data_t * this ) { 17 this->state = BARGE; 17 this->last_thread = NULL; 18 this->last_signaller = NULL; 18 19 } 19 20 … … 28 29 //------------------------------------------------------------------------------ 29 30 void wait_op( global_data_t * mutex a, global_data_t * mutex b, unsigned i ) { 30 wait( &cond ); 31 a->ran = b->ran = true; 31 wait( &cond, (uintptr_t)this_thread() ); 32 32 33 33 yield( ((unsigned)rand48()) % 10 ); 34 34 35 if(a-> state != SIGNAL || b->state != SIGNAL) {36 sout | "ERROR Barging detected " | a->state | b->state| endl;35 if(a->last_thread != a->last_signaller || b->last_thread != b->last_signaller ) { 36 sout | "ERROR Barging detected, expected" | a->last_signaller | b->last_signaller | "got" | a->last_thread | b->last_thread | endl; 37 37 abort(); 38 38 } 39 39 40 a-> state = b->state = WAITED;40 a->last_thread = b->last_thread = this_thread(); 41 41 42 42 yield( ((unsigned)rand48()) % 10 ); … … 54 54 yield( ((unsigned)rand48()) % 10 ); 55 55 56 a->ran = b->ran = false; 57 a->state = b->state = SIGNAL; 56 a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread(); 58 57 59 signal_block( &cond );58 if( !is_empty( &cond ) ) { 60 59 61 yield( ((unsigned)rand48()) % 10);60 thread_desc * next = front( &cond ); 62 61 63 assert(a->ran == b->ran); 64 if(a->ran) 65 { 66 if(a->state != WAITED || b->state != WAITED) { 67 sout | "ERROR Barging detected" | a->state | b->state | endl; 62 if( ! signal_block( &cond ) ) { 63 sout | "ERROR expected to be able to signal" | endl; 64 abort(); 65 } 66 67 yield( ((unsigned)rand48()) % 10 ); 68 69 if(a->last_thread != next || b->last_thread != next) { 70 sout | "ERROR Barging detected, expected" | next | "got" | a->last_thread | b->last_thread | endl; 68 71 abort(); 69 72 } … … 81 84 //------------------------------------------------------------------------------ 82 85 void barge_op( global_data_t * mutex a ) { 83 a-> state = BARGE;86 a->last_thread = this_thread(); 84 87 } 85 88 -
src/tests/sched-int-disjoint.c
r8f61052c r2ab67b9 78 78 signal( &cond, a, &data ); 79 79 80 int pauses = (unsigned)rand48() % 10; 81 for(int i = 0; i < pauses; i++) { 82 yield(); 83 } 80 yield( (unsigned)rand48() % 10 ); 84 81 85 82 //This is technically a mutual exclusion violation but the mutex monitor protects us
Note: See TracChangeset
for help on using the changeset viewer.