Address

Author Topic: POSIX/SUS/WTF!!??  (Read 1159 times)

NerthBox

  • FamiLAB Member
  • Newbie
  • *
  • Posts: 16
    • View Profile
POSIX/SUS/WTF!!??
« on: April 28, 2014, 09:59:17 AM »
Well, in my recent discoveries, I have learned about POSIX/SUS cglib <termios.h> etc..etc.. and system programming on Linux with C/C++.
But the lack of documentation (more of a lack of usable examples) is driving me nuts!
If anyone has experience with this,  and can maybe offer some code for me to look at, it would be much awesome!
My goal is to utilize Linux itself for a ton of my projects, that all for no good reason depend on high level languages and programs written in C! So I believe i can do all i want with ONE program that can have the whole OS dedicated to it. Something fun to try with the Pi!


anyway
I will be at the lab most this week
thanks

Waterbury

  • FamiLAB Member
  • Sr. Member
  • *
  • Posts: 345
  • You can do it. We can help!
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #1 on: April 28, 2014, 10:38:10 AM »
Try to modify the Makefile with the -o3 option. Optimize the binary for runtime on the Pi. The ARMv6 of the Pi will thank you. Make sure to set up the swap to offload the stack in RAM.
"The American, by nature, is optimistic. He is experimental, an inventor and a builder who builds best when called upon to build greatly." ~ John F. Kennedy

Waterbury

  • FamiLAB Member
  • Sr. Member
  • *
  • Posts: 345
  • You can do it. We can help!
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #2 on: April 28, 2014, 10:46:28 AM »
Using the Pi as a bare metal ALU is more preferred IMHO. The higher level Linux compiles cannot stand up to the performance gained by assembling ARM binaries. The documentation for ARM compiles is better than the documentation of C libs in the closed environment. I wrote my own OS built for such a purpose. Try to utilize the MPEG decoder as a HW accelerator if you follow in my endeavors.


The Pi, like any closed system is Turing Complete. Theoretically any software should execute given enough resources.
"The American, by nature, is optimistic. He is experimental, an inventor and a builder who builds best when called upon to build greatly." ~ John F. Kennedy

Hybridsix

  • Administrator
  • Sr. Member
  • *****
  • Posts: 441
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #3 on: April 28, 2014, 10:50:02 AM »
Accessing the direct memory registers on the Pi is much easier now that the whole core is open source. This makes the layout of your instruction set-specific optimizations more readable by peer review. The alignment of your data directives can be further optimized by using a macro perhaps?

darkmoonsinger

  • Treasurer
  • Administrator
  • Hero Member
  • *****
  • Posts: 701
  • I am no one but all that I am.
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #4 on: April 28, 2014, 11:10:45 AM »
Speaking to Waterbury's assertion that the Pi is both a closed system and Turing Complete, I'd argue that the potential exists for any program written and run on the Pi, as it's TC, to run in NP-time and P-time at the same time, thus proving that P = NP and then the universe explodes. So I would avoid writing anything for the Pi in a higher-level language so as to avoid the possibility of a program running in P-time and NP-time. I suggest using only the lambda calculus implemented in assembly and altogether avoiding the POSIX libraries; if you have to write in a higher-level language and there's no other option, you should consider exclusively using Boost, as it's the fastest, best, and least buggy option there is.

bethjaneway

  • FamiLAB Member
  • Sr. Member
  • *
  • Posts: 331
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #5 on: April 28, 2014, 12:10:16 PM »
back in my online dating days, I had a quiz on my profile.

What operating system do you use?
1) Windows. I need functionality more than coolness.
2) Mac. I rebel against the status quo
3) Linux. I prefer to write my own operating systems.
4) Assembly. I need total control. But I am currently logged in at the library since I haven't gotten the graphics card to work yet.
Note: To improve mood, administer chocolate.

NerthBox

  • FamiLAB Member
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #6 on: April 28, 2014, 05:03:23 PM »
I hate to say, i have no idea what any of you mean.
All I am really trying to do is not use python or whatever to utilize serial input from an arduino into ANY linux flavor. and using the std C api for linux is the most (in all of my research) direct way to read from the ttyACM0 and then make a decision on that info in a c++ program.

nanolith

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: POSIX/SUS/WTF!!??
« Reply #7 on: May 06, 2014, 03:26:35 PM »
I'm late to the party, but look into libev or libevent.  Once you go down the route of integrating serial and other protocols into your application, you'll want a good abstraction layer above select/poll that is easy to write to.  If you want to stick with POSIX/C, this is a good simple library for giving you what you need without digging into the cruft of asynchronous I/O.

There are plenty of examples of setting up Linux based serial apps using termios online.  Just search for Linux serial termios.

Let me know if you need any further help.  I've put together plenty of serial stuff with the Pi and the Beaglebone using straight C or C++.