Add a tool for testing various IPC methods
Change-Id: I2fc2e641cee4d26b9ec865f4d7555036def3abfd
diff --git a/aos/linux_code/init.cc b/aos/linux_code/init.cc
index 80c71e3..09b11a2 100644
--- a/aos/linux_code/init.cc
+++ b/aos/linux_code/init.cc
@@ -146,6 +146,9 @@
}
void SetCurrentThreadRealtimePriority(int priority) {
+ // Make sure we will only be allowed to run for 3 seconds straight.
+ SetSoftRLimit(RLIMIT_RTTIME, 3000000, true);
+
struct sched_param param;
param.sched_priority = priority;
if (sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) {
@@ -153,6 +156,13 @@
}
}
+void PinCurrentThreadToCPU(int number) {
+ cpu_set_t cpuset;
+ CPU_ZERO(&cpuset);
+ CPU_SET(number, &cpuset);
+ PRCHECK(pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset));
+}
+
void SetCurrentThreadName(const ::std::string &name) {
if (name.size() > 16) {
LOG(FATAL, "thread name '%s' too long\n", name.c_str());