Add nosv mutex API events
This commit is contained in:
		
							parent
							
								
									70f34e9e33
								
							
						
					
					
						commit
						aaa7769448
					
				| @ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | ||||
| 
 | ||||
| - Consistency check for events emitted when the kernel has removed the thread | ||||
|   from the CPU. | ||||
| - The nOS-V model version is bumped to 2.1.0. | ||||
| - Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and | ||||
|   `nosv_mutex_unlock` events VA{lLtTuU}. | ||||
| 
 | ||||
| ## [1.8.0] - 2024-03-18 | ||||
| 
 | ||||
|  | ||||
| @ -17,7 +17,7 @@ window_comm_lines_enabled true | ||||
| window_flags_enabled false | ||||
| window_noncolor_mode true | ||||
| window_custom_color_enabled true | ||||
| window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:0,99,162} | ||||
| window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{25.000000000000:0,99,162} | ||||
| window_logical_filtered true | ||||
| window_physical_filtered false | ||||
| window_comm_fromto true | ||||
|  | ||||
| @ -17,7 +17,7 @@ window_comm_lines_enabled true | ||||
| window_flags_enabled false | ||||
| window_noncolor_mode true | ||||
| window_custom_color_enabled true | ||||
| window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:0,99,162} | ||||
| window_custom_color_palette {6.000000000000:94,0,0},{7.000000000000:153,114,0},{9.000000000000:124,213,228},{10.000000000000:242,239,141},{11.000000000000:0,70,0},{19.000000000000:195,96,151},{20.000000000000:255,162,255},{21.000000000000:203,255,3},{22.000000000000:7,255,12},{23.000000000000:21,224,189},{25.000000000000:0,99,162} | ||||
| window_logical_filtered true | ||||
| window_physical_filtered false | ||||
| window_comm_fromto true | ||||
|  | ||||
| @ -615,7 +615,7 @@ List of events for the model *tampi* with identifier **`T`** at version `1.0.0`: | ||||
| 
 | ||||
| ## Model nosv | ||||
| 
 | ||||
| List of events for the model *nosv* with identifier **`V`** at version `2.0.0`: | ||||
| List of events for the model *nosv* with identifier **`V`** at version `2.1.0`: | ||||
| <dl> | ||||
| <dt><a id="VTc" href="#VTc"><pre>VTc(u32 taskid, u32 typeid)</pre></a></dt> | ||||
| <dd>creates task %{taskid} with type %{typeid}</dd> | ||||
| @ -693,6 +693,18 @@ List of events for the model *nosv* with identifier **`V`** at version `2.0.0`: | ||||
| <dd>enters nosv_detach()</dd> | ||||
| <dt><a id="VAE" href="#VAE"><pre>VAE</pre></a></dt> | ||||
| <dd>leaves nosv_detach()</dd> | ||||
| <dt><a id="VAl" href="#VAl"><pre>VAl</pre></a></dt> | ||||
| <dd>enters nosv_mutex_lock()</dd> | ||||
| <dt><a id="VAL" href="#VAL"><pre>VAL</pre></a></dt> | ||||
| <dd>leaves nosv_mutex_lock()</dd> | ||||
| <dt><a id="VAt" href="#VAt"><pre>VAt</pre></a></dt> | ||||
| <dd>enters nosv_mutex_trylock()</dd> | ||||
| <dt><a id="VAT" href="#VAT"><pre>VAT</pre></a></dt> | ||||
| <dd>leaves nosv_mutex_trylock()</dd> | ||||
| <dt><a id="VAu" href="#VAu"><pre>VAu</pre></a></dt> | ||||
| <dd>enters nosv_mutex_unlock()</dd> | ||||
| <dt><a id="VAU" href="#VAU"><pre>VAU</pre></a></dt> | ||||
| <dd>leaves nosv_mutex_unlock()</dd> | ||||
| <dt><a id="VHa" href="#VHa"><pre>VHa</pre></a></dt> | ||||
| <dd>enters nosv_attach()</dd> | ||||
| <dt><a id="VHA" href="#VHA"><pre>VHA</pre></a></dt> | ||||
|  | ||||
| @ -39,6 +39,8 @@ Track changes in emulator model versions. | ||||
| 
 | ||||
| ## nOS-V | ||||
| 
 | ||||
| - nosv 2.1.0 | ||||
|     - Add support for `nosv_mutex_lock`, `nosv_mutex_trylock` and `nosv_mutex_unlock` events VA{lLtTuU}. | ||||
| - nosv 2.0.0 | ||||
|     - Add support for parallel tasks, adding a new `bodyid` argument in `VT*` events. | ||||
|     - Remove support for old attach events `VH{aA}`. | ||||
|  | ||||
| @ -59,6 +59,12 @@ static const int ss_table[256][256][3] = { | ||||
| 		['A'] = { CHSS, POP,  ST_API_ATTACH }, | ||||
| 		['e'] = { CHSS, PUSH, ST_API_DETACH }, | ||||
| 		['E'] = { CHSS, POP,  ST_API_DETACH }, | ||||
| 		['l'] = { CHSS, PUSH, ST_API_MUTEX_LOCK }, | ||||
| 		['L'] = { CHSS, POP,  ST_API_MUTEX_LOCK }, | ||||
| 		['t'] = { CHSS, PUSH, ST_API_MUTEX_TRYLOCK }, | ||||
| 		['T'] = { CHSS, POP,  ST_API_MUTEX_TRYLOCK }, | ||||
| 		['u'] = { CHSS, PUSH, ST_API_MUTEX_UNLOCK }, | ||||
| 		['U'] = { CHSS, POP,  ST_API_MUTEX_UNLOCK }, | ||||
| 	}, | ||||
| 	/* FIXME: Move thread type to another channel, like nanos6 */ | ||||
| 	['H'] = { | ||||
|  | ||||
| @ -37,6 +37,9 @@ enum nosv_ss_values { | ||||
| 	ST_API_SCHEDPOINT, | ||||
| 	ST_API_ATTACH, | ||||
| 	ST_API_DETACH, | ||||
| 	ST_API_MUTEX_LOCK, | ||||
| 	ST_API_MUTEX_TRYLOCK, | ||||
| 	ST_API_MUTEX_UNLOCK, | ||||
| 	ST_WORKER, | ||||
| 	ST_DELEGATE, | ||||
| 
 | ||||
|  | ||||
| @ -60,6 +60,9 @@ static struct ev_decl model_evlist[] = { | ||||
| 	PAIR_E("VAc", "VAC", "nosv_schedpoint()") | ||||
| 	PAIR_E("VAa", "VAA", "nosv_attach()") | ||||
| 	PAIR_E("VAe", "VAE", "nosv_detach()") | ||||
| 	PAIR_E("VAl", "VAL", "nosv_mutex_lock()") | ||||
| 	PAIR_E("VAt", "VAT", "nosv_mutex_trylock()") | ||||
| 	PAIR_E("VAu", "VAU", "nosv_mutex_unlock()") | ||||
| 
 | ||||
| 	/* FIXME: VHA and VHa are not subsystems */ | ||||
| 	{ "VHa", "enters nosv_attach()" }, | ||||
| @ -73,7 +76,7 @@ static struct ev_decl model_evlist[] = { | ||||
| 
 | ||||
| struct model_spec model_nosv = { | ||||
| 	.name    = model_name, | ||||
| 	.version = "2.0.0", | ||||
| 	.version = "2.1.0", | ||||
| 	.evlist  = model_evlist, | ||||
| 	.model   = model_id, | ||||
| 	.create  = model_nosv_create, | ||||
| @ -144,6 +147,9 @@ static const struct pcf_value_label nosv_ss_values[] = { | ||||
| 	{ ST_API_SCHEDPOINT,   "API: Scheduling point" }, | ||||
| 	{ ST_API_ATTACH,       "API: Attach" }, | ||||
| 	{ ST_API_DETACH,       "API: Detach" }, | ||||
| 	{ ST_API_MUTEX_LOCK,   "API: Mutex lock" }, | ||||
| 	{ ST_API_MUTEX_TRYLOCK,"API: Mutex trylock" }, | ||||
| 	{ ST_API_MUTEX_UNLOCK, "API: Mutex unlock" }, | ||||
| 	{ ST_WORKER,           "Thread: Worker" }, | ||||
| 	{ ST_DELEGATE,         "Thread: Delegate" }, | ||||
| 	{ EV_SCHED_SEND,       "EV Scheduler: Send task" }, | ||||
|  | ||||
| @ -20,6 +20,7 @@ test_emu(require-missing.c | ||||
|   REGEX "all .* models are enabled") | ||||
| test_emu(parallel-tasks.c) | ||||
| test_emu(nest-to-parallel.c) | ||||
| test_emu(mutex.c) | ||||
| 
 | ||||
| test_emu(bad-nest-same-task.c SHOULD_FAIL | ||||
|   REGEX "body_execute: refusing to run body(id=1,taskid=1) in Paused state, needs to resume intead") | ||||
|  | ||||
| @ -50,6 +50,12 @@ INSTR_0ARG(instr_nosv_attach_enter, "VAa") | ||||
| INSTR_0ARG(instr_nosv_attach_exit,  "VAA") | ||||
| INSTR_0ARG(instr_nosv_detach_enter, "VAe") | ||||
| INSTR_0ARG(instr_nosv_detach_exit,  "VAE") | ||||
| INSTR_0ARG(instr_nosv_mutex_lock_enter,    "VAl") | ||||
| INSTR_0ARG(instr_nosv_mutex_lock_exit,     "VAL") | ||||
| INSTR_0ARG(instr_nosv_mutex_trylock_enter, "VAt") | ||||
| INSTR_0ARG(instr_nosv_mutex_trylock_exit,  "VAT") | ||||
| INSTR_0ARG(instr_nosv_mutex_unlock_enter,  "VAu") | ||||
| INSTR_0ARG(instr_nosv_mutex_unlock_exit,   "VAU") | ||||
| INSTR_0ARG(instr_nosv_attached, "VHa") /* deprecated */ | ||||
| INSTR_0ARG(instr_nosv_detached, "VHA") /* deprecated */ | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										32
									
								
								test/emu/nosv/mutex.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								test/emu/nosv/mutex.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| /* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
 | ||||
|  * SPDX-License-Identifier: GPL-3.0-or-later */ | ||||
| 
 | ||||
| #include "compat.h" | ||||
| #include "instr.h" | ||||
| #include "instr_nosv.h" | ||||
| 
 | ||||
| /* Test the nosv_mutex_lock(), nosv_mutex_trylock() and nosv_mutex_unlock() API
 | ||||
|  * events, introduced in the nOS-V model 2.1.0 */ | ||||
| 
 | ||||
| int | ||||
| main(void) | ||||
| { | ||||
| 	instr_start(0, 1); | ||||
| 	instr_nosv_init(); | ||||
| 
 | ||||
| 	instr_nosv_mutex_lock_enter(); | ||||
| 	sleep_us(100); | ||||
| 	instr_nosv_mutex_lock_exit(); | ||||
| 
 | ||||
| 	instr_nosv_mutex_trylock_enter(); | ||||
| 	sleep_us(100); | ||||
| 	instr_nosv_mutex_trylock_exit(); | ||||
| 
 | ||||
| 	instr_nosv_mutex_unlock_enter(); | ||||
| 	sleep_us(100); | ||||
| 	instr_nosv_mutex_unlock_exit(); | ||||
| 
 | ||||
| 	instr_end(); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
| @ -42,6 +42,7 @@ nosv_test(several-tasks.c SORT) | ||||
| nosv_test(init-nested.c SORT) | ||||
| nosv_test(parallel-tasks.c SORT) | ||||
| nosv_test(inline.c SORT) | ||||
| nosv_test(mutex.c SORT) | ||||
| 
 | ||||
| # Test multiple instrumentation levels | ||||
| nosv_test(several-tasks.c SORT NAME several-tasks-level-0 LEVEL 0) | ||||
|  | ||||
							
								
								
									
										46
									
								
								test/rt/nosv/mutex.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								test/rt/nosv/mutex.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| /* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
 | ||||
|  * SPDX-License-Identifier: GPL-3.0-or-later */ | ||||
| 
 | ||||
| #include <nosv.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| #include "common.h" | ||||
| #include "compat.h" | ||||
| 
 | ||||
| int | ||||
| main(void) | ||||
| { | ||||
| 	nosv_task_t task; | ||||
| 	nosv_mutex_t mutex; | ||||
| 
 | ||||
| 	if (nosv_init() != 0) | ||||
| 		die("nosv_init failed"); | ||||
| 
 | ||||
| 	if (nosv_attach(&task, NULL, "attached-task", 0) != 0) | ||||
| 		die("nosv_attach failed"); | ||||
| 
 | ||||
| 
 | ||||
| 	if (nosv_mutex_init(&mutex, NOSV_MUTEX_NONE) != 0) | ||||
| 		die("nosv_mutex_init failed"); | ||||
| 
 | ||||
| 	if (nosv_mutex_lock(mutex) != 0) | ||||
| 		die("nosv_mutex_lock failed"); | ||||
| 
 | ||||
| 	if (nosv_mutex_trylock(mutex) != NOSV_ERR_BUSY) | ||||
| 		die("nosv_mutex_trylock failed"); | ||||
| 
 | ||||
| 	if (nosv_mutex_unlock(mutex) != 0) | ||||
| 		die("nosv_mutex_unlock failed"); | ||||
| 
 | ||||
| 	if (nosv_mutex_destroy(mutex) != 0) | ||||
| 		die("nosv_mutex_destroy failed"); | ||||
| 
 | ||||
| 
 | ||||
| 	if (nosv_detach(0) != 0) | ||||
| 		die("nosv_detach failed"); | ||||
| 
 | ||||
| 	if (nosv_shutdown() != 0) | ||||
| 		die("nosv_shutdown failed"); | ||||
| 
 | ||||
| 	return 0; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user