Skip to content

Commit

Permalink
Use parking_lot mutex for CalSeg::sync, use OS mutex for MPSC queue
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerZ committed Sep 29, 2024
1 parent 8c8b2ae commit b932d55
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 172 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ lazy_static = "1.4.0"
once_cell = "1.19.0"
static_cell = "2.1.0"

# More compact and efficient implementations of the standard synchronization primitives
# Used for the mutex in CalSeg::sync()
parking_lot = "0.12.3"

# proc-macro A2L serializer for structs
xcp_type_description = { path = "./xcp_type_description/", optional = true}
xcp_type_description_derive = { path = "./xcp_type_description/xcp_type_description_derive/", optional = true }
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ All measurement and calibration code instrumentation is non blocking and the tri
There are no heap allocation during runtime, except for the lazy registrations of and for A2L generation.
build.rs automatically builds a minimum static C library from individially preconfigured core XCPlite sources.
On C level, there is a synchronisation mutex or spinlock for the mpsc transmit queue.
On C level, there is a synchronisation mutex for the mpsc transmit queue.
The C code has the option to start the server with 2 normal threads for rx and tx socket handling.
The generated A2L file is finalized on XCP connect and provided for upload via XCP.
Expand All @@ -288,15 +288,16 @@ These concepts are currently not supported by the A2L update tools, though A2L g
The EPK version string in the A2L file can be set by the application. It resides a seperate, hardcoded const memory segment.
## Future improvements
## Possible improvements
- Create a minimal lock MPSC event queue, increase queue efficiency (optimize mutex contention) for many daq lists and events
- Support more types of calibration parameters, including types for curves and maps with axis
- Avoid the mutex lock in CalSeg::Sync when there is no pending parameter modification
- Improve the meta data annotations of the A2L serializer
- Reduce the number of heap allocations and strings, reduce the overall memory footprint
- Add sub groups of measurements for event instances
- Add support to decribe the application clock domain in rust
- Improve the pointer provenance checks in XcpEvent
- Add support to describe the application clock domain in rust
- Provide a no-std version and create a embassy example
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_thread_demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn main() {

// Test
thread::sleep(Duration::from_millis(1000));
xcp.write_a2l().unwrap();
xcp.write_a2l().unwrap(); // @@@@ Remove: force A2L write

t.into_iter().for_each(|t| t.join().unwrap());

Expand Down
2 changes: 1 addition & 1 deletion examples/point_cloud_demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,6 @@ fn main() {
event_point_cloud.trigger();

params.sync();
xcp.write_a2l().unwrap();
xcp.write_a2l().unwrap(); // @@@@ Remove: force A2L write
}
}
2 changes: 1 addition & 1 deletion examples/protobuf_demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,6 @@ fn main() {

thread::sleep(Duration::from_micros(1000000));

xcp.write_a2l().unwrap(); // @@@@ test
xcp.write_a2l().unwrap(); // @@@@ Remove: force A2L write
}
}
2 changes: 1 addition & 1 deletion examples/single_thread_demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fn main() {

thread::sleep(Duration::from_millis(10)); // 100 Hz

xcp.write_a2l().unwrap();
xcp.write_a2l().unwrap(); // @@@@ Remove: force A2L write
}

// Stop the XCP server
Expand Down
Loading

0 comments on commit b932d55

Please sign in to comment.