Do we have a thread library that is compatible with Turbo C? - c

Currently I am developing a program for academic purpose. We use Turbo C because we are requesting for interrupt directly with the hardware.
We can do anything for our project, and I've already chosen a topic. The thing is I think I really need 2 threads in my program. Are there any thread libraries that are compatible with Turbo C in this case?

We use Turbo C because we are
requesting for interrupt directly with
the hardware
Many Windows programs interact directly with the hardware without being written in a DOS environment in Turbo C. Take a look at the WDK for more information about this.

Related

Concurrent programing in plain C - Windows / Linux

I have a function, lets say, callMe(args). I would like to be able to call my function 100 times in the same time (concurrent programing). My function is written in plain C. I want to make it concurrent for Windows and Linux.
Is there any built in support for this in standard C library? Or can you provide some advices, how should I do this in Linux/Windows?
Is pthread good for Linux environments for this?
You can't write a concurrent program in pure standard C99. Concurrent programming is not in standard C99; it requires some operating system specific libraries. However, the latest C11 standard (which has very few implementations today, February 2014 - I know none!) is beginning to add support for threads. On Linux systems I would suggest today to stick to pthreads.
You could use a cross-platform library (like glib from GTK) to ease porting between Windows and Linux. On Linux, it is wrapping pthreads.
I don't know Windows, but Glib -and GTK for GUI applications- is rumored to enable source-compatible coding between Windows & Linux
If your computation is embarrassingly data parallel (like some matrix numerical computations are), consider also OpenCL (notably because it can run on GPGPUs) or OpenMP. If it fits in a message passing paradigm, consider MPI
OpenCL, OpenMP, MPI are rumored to enable source-compatible coding for Linux and for Windows.
In C++11 (which is a different language than C) you have thread support, and the GCC 4.8.2 compiler is supporting them quite well. And Qt or Poco or Boost is a cross-platform C++ library, notably wrapping concurrent primitives.
Whatever concurrent mechanism you are using, beware of synchronization issues.
You always have synchronization with concurrency, at least to wait for the results of each concurrent or parallel sub-computation
You have to use different functions for different platforms.
Its similar like different browsers uses different kind of css property names.
So for linux/mac you can use pthread
And for windows you use CreateThread

What are the limits of C on microcontrollers without operating systems?

I've never programmed a microcontroller. I've been playing around with Arduino and have discovered that the programming language is just C, with boilerplate code dynamically generated by the IDE. So: what can't I do in C/C++ on Arduino/microcontroller without an operating system versus C on Linux/Windows? Should any program that uses nothing but the standard library work? Or are there limits on specialized functions like malloc/free and setjmp/longjmp?
I ask because I want to compile and use an encryption library like openssl or crypto++ an Arduino Due (with a 32 bit arm processor).
There are no limits, except those that are imposed by your compiler. Clearly you cannot make "operating system calls" when you don't have an "operating system", but as long as somebody wrote a library that provides the functionality you need, there are indeed "no limits". Encryption - done. Malloc - easy. TCP/IP - got it. Lots of Arduino libraries. It's fun. Go for it.
Some helpful information at http://www.nongnu.org/avr-libc/user-manual/malloc.html

Is multithreading supported in embedded Keil C?

I am developing an embedded application in LM3S6965 evaluation board using Keil C compiler. Is there any option for creating multithreaded embedded application?
You might want to check out FreeRTOS. It's a pretty simple and light-weight OS that will give you multithreading.
There are lots of other light-weight OSes too.
Multi-threading is not an intrinsic part of C, so is not provided by the compiler at all, but rather by libraries. In that respect, multi-threading can be implemented using any C compiler; it is more a case of choosing (or writing) a suitable library.
Many RTOS kernels exist for ARM Cortex-M, but the the Keil MDK-ARM includes the RTX real-time OS library which supports multi-threading.
The uVision IDE explicitly has an option to include the RTX library, and the debugger has a rudimentary level of kernel awareness. RTX itself is fairly primitive, but suited to small projects, and all of Keil's other middle-ware such as TCP/IP, USB, CAN and filesystem work with it directly.

programming for a generic ARM environment in C or C++ on X86

I'm looking for a solution to begin my journey in the ARM world's, i want to use the C as my main language and i'd like to create a basic program using the standard I/O library for this environment.
Also, there is an emulator or something like that which runs on an X86 based PC? I can try some operative systems on this kind of emulator like Debian for ARM?
Thanks.
If you don't have any specific hardware platform in mind already, then QEMU might be working for the emulation part.
For the sake of completeness: Skyeye might be an alternative to QEMU, although it does not seem as well documented (at least not in english).

C and POSIX Pthreads

I have just started reading about threading in C, using pthreads. I know that Pthreads are available for Windows, but do multithreaded WIndows based C/C++ applications mostly use Pthreads?
Also in Unix/Linux are Pthreads the main way developers write multithreaded C/C++ code?
No, most will use the thread abstraction of the application/gui library they are using, e.g. MFC. Or in the plain C case, using the windows API directly.
Pthreads stands for "POSIX" threads, which is basically standarized unix(-like), a standard that has little meaning on Windows outside dedicated POSIX emulations like cygwin.
The new C++ Standard, C++11, has support for portable threads. I'd definitely go with that, except that Visual Studio hasn't implemented them yet.

Resources