add my own broken example for uiowa-threads.c
This commit is contained in:
		
							parent
							
								
									8141a18cab
								
							
						
					
					
						commit
						a5638de011
					
				
					 3 changed files with 34 additions and 1 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -33,3 +33,4 @@ multibrot-openmp.png | |||
| hello-openmp | ||||
| mandelbrot-openmp | ||||
| positional-format-strings | ||||
| uiowa-threads-my-example | ||||
|  |  | |||
							
								
								
									
										6
									
								
								Makefile
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								Makefile
									
										
									
									
									
								
							|  | @ -7,7 +7,8 @@ CFLAGS_OPENMP=$(CFLAGS) -fopenmp | |||
| 
 | ||||
| TARGETS=approximate-pi linked-list mandelbrot threads circular-buffer structs \
 | ||||
| 				ncurses-pong bit-fuckery bit-fuckery2 checkcheck multibrot bloom \
 | ||||
| 				wo-lernen lua-foo binsearch test-inline-assembly uiowa-threads-example \
 | ||||
| 				wo-lernen lua-foo binsearch test-inline-assembly \
 | ||||
| 				uiowa-threads-example uiowa-threads-my-example \
 | ||||
| 				mtrace-test av-variance undefined-behaviour \
 | ||||
| 				multibrot-openmp hello-openmp mandelbrot-openmp \
 | ||||
| 				positional-format-strings | ||||
|  | @ -81,6 +82,9 @@ mtrace-test.txt: mtrace-test.trace | |||
| uiowa-threads-example: uiowa-threads.o uiowa-threads-example.c | ||||
| 	$(CC) $(CFLAGS) -o $@ $^ | ||||
| 
 | ||||
| uiowa-threads-my-example: uiowa-threads.o uiowa-threads-my-example.c | ||||
| 	$(CC) $(CFLAGS) -o $@ $^ | ||||
| 
 | ||||
| av-variance: av-variance.c | ||||
| 	$(CC) $(CFLAGS) -o $@ $< -lm | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										28
									
								
								uiowa-threads-my-example.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								uiowa-threads-my-example.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| #include <stdio.h> | ||||
| #include "uiowa-threads.h" | ||||
| 
 | ||||
| void test_thread(int n) { | ||||
|   for (int i=0; i<10; i++) { | ||||
|     printf("thread %d: %d\n", n, i); | ||||
|     thread_relinquish(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void test_thread2(int n) { | ||||
|   for (int i=0; i<10; i++) { | ||||
|     printf("thread %d: %d\n", n, i); | ||||
|     thread_relinquish(); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| int main() | ||||
| { | ||||
|   thread_manager_init(); | ||||
|   thread_startup_report(); | ||||
| 
 | ||||
|   thread_launch(4000, test_thread, 1); | ||||
|   thread_launch(4000, test_thread2, 2); | ||||
| 
 | ||||
|   thread_manager_start(); | ||||
|   /* control never reaches this point */ | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue