Anyway, how about the same resource shared by two threads ?
I have to use the pthread_mutex_t to lock it right ?
I am not sure when to lock the resource. Let's say, there are 2 threads, one is to write data, and another is to read data, so in either reading or writing, we lock the resource ? or we lock only when we write ?
User Profile
Collapse
-
Thank gpraghuram
oh yes....you're right. I forget to set the attribute to be JOINABLE, and join them to the main thread, so that the main thread could wait for all of the child threads to be terminated.Leave a comment:
-
socket and pthread
Hi all.
I have a socket. I want to create two threads, one is to read from socket, and another is to write to socket. However, I want these two threads to be able to share the same data, so I created a mutex to lock the resource.
I don't know what happens with my two threads, but it always quits after it did some tasks.
Code:#include "camel.h" #include "irc.h" pthread_t gtid;
-
Oh god
The problem is at last solved, I forgot to import a module named inspect :)Leave a comment:
-
UnboundLocalError
I am stuck at the a small code as the following:
This is module main, the main entry of the application :
Code:from irc_log_mod import * from irc_chatter_mod import * from inspect import * from irc_global_mod import * def main(): try: curFrame = currentframe() writeLog(LOG, curFrame.f_code.co_filename,
-
Code:void *xyz; struct abcd { int a; }; struct abcd a,*ptra; ptra=&a; xyz=(struct abcd *)ptra; //doesnt work but no error shown. . . printf("%d \n",xyz->a); }
You declared xyz as a pointer to void.
Then after you do like :
xyz = (struct abcd *)ptra; that ptra's type is a pointer...Leave a comment:
-
In the log file, there should be included :
- date of logging
- file : in what file that produces the log ?
- function : in what function ?
- line : the line number
- debug level : in which level is this log ?
- status : success... failed, ... error code ...etc
- desc : the error description.
This is the incomplete sample code to log something:
Code:Full code removed, please read posting guidelines
Leave a comment:
-
Well, this command below works with GCC.
Example :
- path_header_fil e : the path to header files of that library
- path_lib
- name_of_lib : the file name of .lib
so the command built against that library is :
gcc -Ipath_header_fi le -Lpath_lib -lname_of_lib -o your_source your_source.c
If that goes smoothly, copy the DLL file ( always provided with the library ) to the same directory of your...Leave a comment:
-
The library are of two kinds static and dynamic library
The static library which is known as .lib on window platform and .a on Unix-like system. the static library is needed in the linking phase after you have compiled your code successfully because only the library can understand what have to do with the function you called in your source code. The linker, may be, read through your object file and copy the function implementation in the library...Leave a comment:
-
Please look at this
Code:........................................................... void input_data(struct database*data_ptr) { int i_tmp; float f_tmp; string s_tmp; cout<<"enter name:"; cin >>s_tmp;data_ptr->name = s_tmp; cout << "enter id_number :"; cin >> i_tmp;data_ptr->id_number = i_tmp; cout << "enter
Leave a comment:
-
Could you please put the code bracket around your code for readability; and write us the error message which compiler produce ( with line number ) to make us easy to solve your problem, if that is a syntax error ?Leave a comment:
-
Well, I find nothing wrong with your code beside the incompatibility of the data type u declared and the inputted data.
Example :
MONSTER : should be declare as an array of char not char.
So please reconsider this case again.
NOTE : One more thing, I would like to say that even your data type should be integer, yet you have to declare it as an array of char to prevent any unexpected error occurred when user input the char...Leave a comment:
-
As you mentioned above, the designed constraint only allows the string input and never number type. so i better not speak something about this ( but wait you should consider this case too before shipping your .exe to your customer).
Yet I found another problem with this
How can u decrypt this data : 334 ?
if you split like this 3, 3 and 4 so it will be CCD
if that comes to 3, and 34 so it will be Cb
and if that...Leave a comment:
-
Yep you can prompt a user to press any key before exiting; yet you can launch your command prompt and execute your .exe to see what is displayed.
However ( this is not what you asked for ), I found that your code does not really count the number of vowels or consonant of the inputted string from users. It had better that you redesign your code again to make it work as what is required.Leave a comment:
-
Code:main.obj : error LNK2001: unresolved external symbol "private: static int * * Binary::mask" (?mask@Binary@@0PAPAHA) fatal error LNK1120: 1 unresolved externals
Leave a comment:
No activity results to display
Show More
Leave a comment: