Best way to multi-thread? [closed] - c

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
What is the best way to multi-thread in the C language? I want something that is very efficient and not a CPU hog. Thanks.

The correct (standard) way to do this on C and Windows is with __beginthreadex.
This is usually preferred to calling CreateThread directly as CreateThread doesn't init C runtime support for the thread. So if you create a thread using CreateThread, and call a CRT function, bad stuff can/will happen.
Note that __beginthreadex calls CreateThread internally, but performs some other work behind the scenes.

If you're on a UNIX-based platform (Linux or Mac OS X) your best option is POSIX threads. They're the standard cross-platform way to multithread in a POSIX environment. They can also be used in Windows, but there are probably better (more native) solutions for that platform.

Your question is a bit general to answer effectively. You might look into such things as:
CreateThread in the windows SDK
boost::thread

Related

Compiler/language runtime vs. Middleware [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What are the specific operations a language runtime does that an operating system does not? How is a language runtime different from a middleware?
This depends on the operating system and the runtime. libc is a good example of a language runtime and the linked article on Wikipedia gives a good overview of what it does. Generally the goal of a language runtime is to provide implementations of standard basic functionality which is likely to be implemented differently between the operating systems the language supports, or functionality which is extremely common, but not provided by the operating system.
Middleware is a very general concept but it simply refers to software placed between two systems as an abstraction layer. You could consider a language runtime as a form of middleware in some contexts.

socket library for MS-DOS (C language) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I need to write client and server applications for MS-DOS using C language.
I don't want to start from scratch and implement sockets.
Can you advice me library in which socket functionality is implemented and for which exist good manuals and examples.
I already tried mTCP library: I got source files from it, added sources from example file and tried to Compile in Turbo C, but it raises a lot of errors it will be very hard task for me to cope with them.
Try libnet. According to it's web page (http://libnet.sourceforge.net/) it supports DOS systems (djgpp compiler), though I personally haven't tried it on DOS.
There is also WATTCP: http://www.erickengelke.com/wattcp/
Have you tried that?

Why does the C89 library not contain functions to create/delete/rename/remove a directory? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I apologize for my bad English.
Why does the C89 library not contain functions to create/delete/rename/remove a directory? Or maybe I didn't find that? I see functions for some file operations only, but not for directories.
Thank you
Best Regards
Otherwise, <dirent.h> header file is now pseudo-standard: both MinGW and GCC have it. So, you can handle directories on a conventional personnal computer, without too much trouble.
Traditionally (and C89 is tradition) the directory structure is seen as part of the operating system, and at the time (1989) there were still OS arround that had incompatible concepts for that.
Nowadays, there would perhaps be enough common ground to integrate such a thing in C, as it is e.g now done for threading in C11, but I am not aware of an initiative to do so.

What free JIT compilers are there today, and which is easier to use? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I will start writing a JIT/interpreter for a small language, and would like to use some of the free JIT tools/libraries available today. What are my options (I only know of libjit, LLVM and GNU lightning), and which would be the easier to use (but not too slow)?
The requiremens would be:
Compiling time is not important
Execution time is important, but so long as using the JIT compiler isn't too hard
Ease of use is important
No garbage collection necessary.
Actually, no run-time environment necessary (I'd really just want the JIT: compile into a memory region, then take the pointer and start executing the generated code)
Development will be done in plain standard C (no C++, no platform-specific features), with pthreads.
Plain standard C with good execution time? you must be looking for LuaJIT(actually dynasm which is the backend, but thats still part of LuaJIT), which is a tracing JIT compiler (where as most of those mentioned are static). It does have garbage collection, but it can easy be taken out or modified (there is a planned overhaul of it soonish), and it has a native FFI, so it can easily do external binding (from a C level, so you don't always have to get into the nitty gritty).
Best part, its totally public domain code, and the code is the documentation (which is nice as its well structured).

graphics in C for learning [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I want to develop some graphical application in C using gcc compiler on Linux.
Which graphics library shall I use to start with? How can I start developing graphics appication on Linux using C?
If you are talking about straight graphics look at:
SDL
GGI (very simple)
If you are talking GUI, QT would certainly be your best bet.
SDL -- http://www.libsdl.org/
Very straightforward to use, and powerful.
If you want pure C (vs C++), there's SDL: SDL, a standard in C library.
If you like C++, there's also SFML: SFML

Resources