pthreads mutex vs semaphore
What is the difference between semaphores and mutex provided by pthread library ? ...
What is the difference between semaphores and mutex provided by pthread library ? ...
I wanted to plot the wave-form of the .wav file for the specific plotting width. Which method should I use to display correct waveform plot ? Any Suggestions , tutorial , links are welcomed.... ...
Does anyone know how I can print and count what I printed? Say I have a number I am printing via printf or cout. How could I count the actual number of digits I have printed out? Gracias ...
Is it OK that a char* variable will point to a string (that's written in the source code)? Can I manipulate/modify the space allocated for the literal string as long as I'm not exceeding it's length? As much as I understand the format of an executable, it's fine, but I want to be sure. Thank you :) ...
Why does this code always produce x=2? unsigned int x = 0; x++ || x++ || x++ || x++ || ........; printf("%d\n",x); ...
On my AVR I have an array of chars that hold color intensity information in the form of {R,G,B,x,R,G,B,x,...} (x being an unused byte). Is there any simple way to write a long int (32-bits) to char myArray[4*LIGHTS] so I can write a 0x00BBGGRR number easily? My typecasting is rough, and I'm not sure how to write it. I'm guessing jus...
Do different data types in C such as char, short, int, long, float, double have different memory alignment boundaries? In a 32 bit word aligned byte addressable operating system, how is accessing a char or short different from accessing an int or float? In both cases, does the CPU read a full 32-bit word? What happens when an int is not ...
Assuming I have some embedded python code containing a function foo, what is the best way to get a reference to that function (for use with PyObject_CallObject)? One way is to have some function register each function along with the function name either manually or through use of reflection. This seems like overkill. Another way is to ...
Possible Duplicate: Why an executable program for a specific CPU does not work on Linux and Windows? Why can't programs written in linux be executd in windows ? Suppose I compile a simple C program containing function calls that are common to both windows and linux, Does the compiler generate different binary under windows and l...
Is there a way in Bison to check the current token stack size? I'd like to use $n with n as a negative number to access a semantic value of another rule but only if the stack is large enough. Thank you. ...
Hi, I have something like this register unsigned int a, b, c; int n; for (n = 0; n < 10; ++n){ c = a + b b = a a = c array[n] = c; } what it does, it doesn't matter. The code runs quickly the way it is now, slower if the register keyword is removed. However, when I add in register before int n, it actually runs slower than now, but f...
lets say I have some global var GLOBAL in main.c, but my main.c has a #include "other.h". But other.h has global var GLOBAL too. How do I let the compiler know which one I meant when I write GLOBAL in main. Is there a "this" keyword that I can use? ...
Hi all, I have an idea for a project based on the Apache module API. So, I am writing my first Apache module to learn the API- just a simple hostname lookup: URL: http://localhost/hostname/stackoverflow.com Response data: Host: stackoverflow.com Address: 69.59.196.211 Address type: AF_INET When the request does not include a hostna...
Specifically, the code sample here works great, but only when the string is stored in a file. Sometimes I need it to process a generated string (stored in a string variable), but I'm having trouble convincing fgets's third parameter to work with string variables because it's a pointer to a FILE structure. Or perhaps there's a functio...
I'm taking a networking class at school and am using C/GDB for the first time. Our assignment is to make a webserver that communicates with a client browser. I am well underway and can open files and send them to the client. Everything goes great till I open a very large file and then I seg fault. I'm not a pro at C/GDB so I'm sorry if t...
hi I am new to C. I am just trying to read each character of the file and print it out but when the file finishes reading, but I am getting a bunch of ? after it finishes reading. How do I fix it? #include <stdio.h> int main(void){ FILE *fr; /* declare the file pointer */ fr = fopen ("some.txt", "r"); /* open the f...
I was just going through some basic stuff as I am learning C. I came upon a question to multiply a number by 7 without using * operator. Basically its like this (x<<3)-x; Now I know about basic bit manipulation operations, But I cant get how do you multiply a number by any other odd number number without using * operator?? Is th...
I have a program main.c which calls header.c with the help of header.h in its program. I know how to compile it in GCC but now i would like to use autotools for it. I would like to know what should be written in Makefile.am to compile main.c? so for example if i have two c files main.c and header.c as given below main.c:- #include<std...
Hi I have a char* aString and I want to write the portion of aString between from and to, what is the most efficient way? I think of a way which writes 1 characters at a time. char* p = aString + from; for (int i =0; i < (to-from); i++) { fprintf(aFile, "%c", p++); } I wonder if there is a faster way? ...
>>> hash("\x01") 128000384 >>> hash("\x02") 256000771 >>> hash("\x03") 384001154 >>> hash("\x04") 512001541 Interesting part is 128000384 x 2 is not 256000771, and also others I am just wondering how that algorithm works and want to learn something on it. Thanks in advance. ...