Add the xyield macro function to yield the CPU.
This commit is contained in:
1 parent
0197fe8484
commit
3ea93dfc85
2 files changed
+10
-7
No files matched your search
+4
-3
@@ -100,7 +100,8 @@ bool WaitForTxIdle(uint32_t ms_timeout) {
|
||||
if (msclock() - start >= ms_timeout) {
|
||||
return false;
|
||||
}
|
||||
msleep(1);
|
||||
|
||||
xyield(); // just to avoid CPU busy loop
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,8 +1150,8 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
|
||||
PrintAndLogEx(INFO, "You can cancel this operation by pressing the pm3 button");
|
||||
show_warning = false;
|
||||
}
|
||||
// just to avoid CPU busy loop:
|
||||
msleep(1);
|
||||
|
||||
xyield(); // just to avoid CPU busy loop
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+6
-4
@@ -24,11 +24,13 @@
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# define sleep(n) Sleep(1000 *(n))
|
||||
# define msleep(n) Sleep((n))
|
||||
# define msleep(n) Sleep((n)) // Sleep(1) may wait 15ms, which is a feature of Windows.
|
||||
# define xyield() Sleep(0) // avoid cpu busy, yield to other threads
|
||||
#else
|
||||
void msleep(uint32_t n); // sleep n milliseconds
|
||||
void msleep(uint32_t n); // sleep n milliseconds
|
||||
# define xyield() msleep(1)
|
||||
#endif // _WIN32
|
||||
|
||||
uint64_t msclock(void); // a milliseconds clock
|
||||
uint64_t usclock(void); // a microseconds clock
|
||||
uint64_t msclock(void); // a milliseconds clock
|
||||
uint64_t usclock(void); // a microseconds clock
|
||||
#endif
|
||||
Reference in new issue
Block a user