|
Yes, this is my last assignment and I am completely baffled. I am done immense research and I even have a snipet of code, mostly pseudo, but I just dont know what to do.....any help?
|
|
|
|
|
Yes, this is my last assignment and I am completely baffled. I am done immense research and I even have a snipet of code, mostly pseudo, but I just dont know what to do.....any help?
|
|
|
|
|
irs97 wrote: the travleing sales person problem
This is not the time to be politically correct.
irs97 wrote: Can anyone please help me...
With which part exactly?
Have you seen this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have scene that, that is what I am having trouple understanding. Branching and bounding is what I need to use but I am not entirely sure how this works. I have read it, I have another book on it, but it just doenst make sense to me how they are finding the lb or lower bound. It seems like the book completely contradicts itself. Any help you could give me on this would be much appreciated.
|
|
|
|
|
Hi
I have written following code but when i execute it, i get an error "segmentation fault". Can anyone plz tell me why i am getting the error. I have surfed the internet for 2 days but still could not get any idea.
Code is
#include <stdio.h><br />
#include <sys/stat.h><br />
#include <stdlib.h><br />
#include <pthread.h><br />
<br />
void* increment(void *msg);<br />
<br />
int count = 0;<br />
int num[1];<br />
pthread_mutex_t mutex;
<br />
int main()<br />
{<br />
FILE *f;<br />
f=fopen("data.txt","w");<br />
num[0]=0;<br />
fwrite(num,sizeof(num),1,f);<br />
fclose(f);<br />
<br />
pthread_t t1, t2, t3, t4, t5;<br />
pthread_mutex_init(&mutex,NULL);<br />
int tid1, tid2, tid3, tid4, tid5;<br />
char msg1[] = "Thread 1";<br />
char msg2[] = "Thread 2";<br />
char msg3[] = "Thread 3";<br />
char msg4[] = "Thread 4";<br />
char msg5[] = "Thread 5";<br />
<br />
pthread_attr_t *attr;<br />
pthread_attr_init(attr);<br />
tid1 = pthread_create( &t1, NULL, increment, (void*)msg1);<br />
tid2 = pthread_create( &t2, NULL, increment, (void*)msg2);<br />
tid3 = pthread_create( &t3, NULL, increment, (void*)msg3);<br />
tid4 = pthread_create( &t4, NULL, increment, (void*)msg4);<br />
tid5 = pthread_create( &t5, NULL, increment, (void*)msg5);<br />
<br />
printf("Threads are created!\n");<br />
<br />
pthread_join(t1, NULL);<br />
pthread_join(t2, NULL);<br />
pthread_join(t3, NULL);<br />
pthread_join(t4, NULL);<br />
pthread_join(t5, NULL);<br />
<br />
return 0;<br />
<br />
}<br />
<br />
<br />
void *increment(void* msg)<br />
{<br />
char *message = (char*)msg;<br />
printf("%s starts: ", message);<br />
for (int i=0;i<20;i++)<br />
{<br />
pthread_mutex_lock( &mutex );<br />
FILE* fh = fopen("data.txt", "r+");<br />
fread(num, sizeof(num), 1, fh);<br />
num[0] = num[0]+1;<br />
printf("%d\n", num[0]);<br />
fseek(fh,0,SEEK_SET);<br />
fwrite(num, sizeof(num), 1, fh);<br />
fclose(fh);<br />
pthread_mutex_unlock( &mutex );<br />
}<br />
pthread_exit(NULL);<br />
}<br />
<br />
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: I have surfed the internet for 2 days but still could not get any idea.
Wouldn't it be faster to use your debugger ? You'll get direct information about where the problem resides and you can check your variables.
|
|
|
|
|
Yeah. . At last i got it. I was getting error when i tried to call pthread_attr_init(). Thanks
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
I am trying to write an app which requires me to convert a String to a WCHAR but not having much luck with a resolution.
Can anyone point out where I am going wrong ?
Pete
|
|
|
|
|
Fritzables wrote: am trying to write an app which requires me to convert a String to a WCHAR but not having much luck with a resolution.
better ASK HERE[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
|
I would like to know how to force the windows installer(deployment project *.vdproj) to overwrite the database files at the time of installing if it is already exist in the user PC. Is there any option for overwrite / no overwrite.
Thanks & Regards,
Suman
-- modified at 1:16 Wednesday 29th November, 2006
|
|
|
|
|
inno setup is very good and can do anything and easy-to-use.
|
|
|
|
|
In my project, i import a dynamically link library developed by other persons. Some functions in the library are used in my project. When some requirements are satisfied, the functions bring up modal dialog boxes and causes my program to pause. I would like to get rid of those modal dialog boxes so that my program can run without any interruptions. Unfortunately, the developers are not available. This means that I have no chance to know what the triggering requirements are. I wonder if it makes sense for me to expect to inhibit those model dialog boxes in some way.
Thanks in advance
|
|
|
|
|
You could use IAT patching if the DLL links to user32 statically. I think this will not work on Win9x however I’m not 100% sure on this.
Steve
|
|
|
|
|
Steve, Thank you for your reply.
Could you please provide more info on IAT patching . I never hear about it before.What is it. How to use it.
|
|
|
|
|
Doing a search of "IAT" at the codeproject will return many results. You could also try Googling for it. "IAT patching" is another phrase you could try searching for. It's a complicated topic if you've never encountered it before.
Steve
|
|
|
|
|
Hi
What is the difference between a process's ID and Handle?
I see that ID is just a number assigned to the process by the system but handle is like pointer of Process.Thay said program database.
But why do we need both of them?
Why is not enough only ID or Handle?
What are the differences?
Arent both of them unique?
Thanks.
|
|
|
|
|
The process ID identifies the process. The process handle is used to perform operations on the process object.
The process id is valid until the process terminates. The process handle is not (you can release
a process handle with CloseHandle() and later obtain process handles with OpenProcess() using the process ID).
The process id will be unique in the system. The process handle is not necessarily unique
(although the object it represents is).
The details of what HANDLEs represent are (thankfully) hidden from us. Otherwise we'd need
different pointer types for all the different Win32 API sets.
Tip: A common handle leak occurs when using CreateProcess() and not releasing the returned
process and thread handles if they're not needed. I see this one often, and was guilty of it
myself for a long time
|
|
|
|
|
Thanks Mark.
I was going to reply to this one, My reply was longer, but your reply should be caligraphed and framed, and put on every system programmers wall. It is Apt and To The point.
LateNightsInNewry
|
|
|
|
|
Thank you Mark Salsbery
Very good explanation.
In what situation are there many handles for a process and windows mange these handles?
Where does windows hold this id and handles?
I mean is there "one" handle table and "one" id table for one sesion?
|
|
|
|
|
sawerr wrote: In what situation are there many handles for a process and windows mange these handles?
Hmmm... in the case of a process handle...say you have another process and you want to terminate
it (with extreme prejudice ). You find the process through some method, obtain a handle to it,
and use that handle in a call to TerminateProcess(). The process itself may have handle(s)
representing its own process as well. Lame example, yes. In the case of process handles maybe
there's not a good example of needing more than one process handle. The point is there CAN be
so to assume handles are unique is not correct.
sawerr wrote: Where does windows hold this id and handles?
I mean is there "one" handle table and "one" id table for one sesion?
Doesn't matter (although it can be interesting, of course). By using handles, the system is free
to implement this any way it needs to, without us having to change our code if the underlying
implementation changes. A handle could be a pointer, an index into an array, a numeric ID,
whatever the implementation uses to identify the object the handle represents. Windows may or
may not have its own handles to processes, I have no idea...the implementation is hidden from
me by handles.
|
|
|
|
|
|
I'm working on a C++ MFC project that has a connection with a MSSQL Server and also makes HTTP requests.
What I would like to do is set up the program so all of the MSSQL traffic takes place on the local network (hardwired ethernet interface) but the HTTP communication takes place on a dialup network (modem interface). Basically, I want all of the HTTP traffic go through the external dialup network, but the database traffic needs to stay inside my LAN.
I'm using the standard MFC CRecordset classes to access the MSSQL Server (using TCP/IP via ODBC) and for my HTTP functions, I am using MFC CInternetSession and CHttpFile classes.
Is there a way I can bind these classes to a specific interface? I'm sure I can enumerate the network interfaces easily enough and identify them, but I'm not sure how to route TCP/IP traffic to a specific interface depending on the task.
Any help is greatly appreciated.
|
|
|
|
|
|
Thanks and rats.
I suppose I'll have to change the processing logic so I'm not trying to run DB and HTTP threads at the same time and reconnect dialup between DB calls.
|
|
|
|