fulldecent / system-bus-radio

Transmits AM radio on computers without radio transmitting hardware.

Home Page:https://fulldecent.github.io/system-bus-radio/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Encapsulate Mac specific behavior

fulldecent opened this issue · comments

A few people have written in to say they are working on a Linux port, which is awesome. One such attempt is at https://github.com/anfractuosity/system-bus-radio/blob/master/main.c

It would be awesome to take the Mac only part and the linux (or general purpose) part and separate them with preprocessor directives.

A note for my C++11 port.
https://github.com/EzoeRyou/system-bus-radio

GCC means g++(core language) with libstdc++(standard library)
Clang means clang++(core language) with libc++(standard sibrary)
MSVC means MSVC2015.

It use std::chrono::high_resolution_clock for retrieving the current time.

On GNU/Linux, GCC's libstdc++ and Clangs libc++ use clock_gettime.
On Mac, Clang use mach_absolute_time.
On Windows, MSVC use QueryPerformanceCounter.

All major C++ implementations has sufficient resolution.

It use std::this_thread::sleep_until for sleep.

On GNU/Linux, GCC and Clang use nanosleep.
On Mac, Clang use nanosleep.
On Windows, MSVC use SleepEx

GNU/Linux and Mac OS X has sufficient resolution.
Windows doesn't have sufficient resolution.
Even by calling timeBeginPeriod(1), Windows C++ implementation has a resolution of 1 milliseconds.

Now for the instruction.
It appears the energy consumption is the main factor of strong electromagnetic radiation.
As reported by #5.
Using as many threads as number of cores(or HT cores) is probably a good strategy.
I ported #5 's code by using C++11's standard library , and <condition_variable>.

My implementation use C++11 for the instruction.

I asked a colleague who is expert at many CPU architectures for the best energy consuming instruction for x86-64, he said,
"the memory access which bypassing the cache is the worst(i.e. best)"

So, original _mm_stream_si128 is probably the best.
It lose the portability to non-x86 architectures though.