|
Thanks man.
It's working.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
If anyone would like to team up and try to win some golf balls , please get ahold of me. Competition Details
Email me at Soliant@Yahoo.com
Soliant
"Every man dies, not every man really lives"
- Braveheart
|
|
|
|
|
Hi,
I know it is a VC++ forum, but i really need help!!! Let's see my code first:
*****************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1)
{
perror("Pipe");
exit(2);
}
if (fork()==0)
{
}
else
{
for (j=1; j<=5; j++)
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid());
operation(f_des, temp);
}
}
while (X>0)
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1)
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message));
waitprocess(getpid());
X--;
}
else
{
printf("error");
}
}
}
}
****************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
Hahahaha. You're an idiot.
|
|
|
|
|
David Wengier wrote:
Hahahaha. You're an idiot.
At first I thought that it was pretty rude. Now I understand what is going on. I think the guy is playing.
|
|
|
|
|
Rama Krishna wrote:
At first I thought that it was pretty rude
I think my reply was very rude.
|
|
|
|
|
Hi everybody!
I have a typical problem here. My application is a multithreaded one. In one of the cases, there are multiple threads which will be using a common buffer which is a member variable of a particular class. This buffer is also allocated memory by one of these threads and to be accessed by the other threads. I am getting a dbg_heap error as debug assertion. How do i go about solving this problem. Please help me out as this is very urgent. Thanx in advance.
regards,
sailesh
|
|
|
|
|
Use one of the synchronization classes to ensure that only one thread can access the thread at a time (or multiple threads can read; but they must be done before a write could be performed).
Look for the .NET Monitor and Mutex classes for more info (more are available but those two are off the top of my head).
James
|
|
|
|
|
But yes, we do intend to add this feature to a future version of the product and we are working very hard to make that the very first future version.
Ronald Laeremans
Visual C++ compiler and libraries team
Cool huh?
That was in response to a question by someone asking when MC++ will have a Windows Forms designer
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Great News!! I'm just getting in to MC++ and finding this a bit of pain.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Derek Lakin wrote:
Great News!! I'm just getting in to MC++ and finding this a bit of pain.
Yeah. Now we won't have to waste 10 minutes to align a text box and a combo box on a form
Just drag/drop/size it. Cool!
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Yes, this really looks like good news
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexpro wrote:
Yes, this really looks like good news
I hope they bring it out as a Service Pack [which is free] instead of as a new version [which won't be free]
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Nish - Native CPian wrote:
I hope they bring it out as a Service Pack [which is free] instead of as a new version [which won't be free]
Surely you'll just be using a pirated version anyway
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
Michael P Butler wrote:
Surely you'll just be using a pirated version anyway
Pirated versions don’t come free MPB. You gotta pay for them. And if you compare salaries, I pay as much of my monthly salary for a pirated CD, that a regular software guy in most other countries would pay for a legal copy of VS .NET.
Anyway I strongly intend to make some money and get myself a LEGAL MSDN subscription.
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Nish may use some pirated software but his VS.NET CDs ARE originals from Microsoft.
Its just that they were originally given to me and we'll just say that Nish pulled them out of the trash can next to my desk right after I tossed them :P
Come to think of it, I still have another set sitting next to me
Michael P Butler wrote:
"Eureka" is Greek for "This bath is too hot"
Nothing gets you thinking like burning your jewels in the morning.
James
|
|
|
|
|
James T. Johnson wrote:
Nish may use some pirated software but his VS.NET CDs ARE originals from Microsoft.
James T. Johnson wrote:
Nothing gets you thinking like burning your jewels in the morning
Now we know what a jewelhole is!
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
I wonder how useful this feature really is. What advantages do we get for doing UI code in MC++ compared to doing it in C# ?
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
Michael P Butler wrote:
What advantages do we get for doing UI code in MC++ compared to doing it in C# ?
None whatsoever
It is good to see that you are slowly subscribing to my views Mike.
|
|
|
|
|
If the rest of your app is in MC++ you don't have to ship a separate assembly for the UI
Otherwise there isn't an advantage that I can think of.
James
|
|
|
|
|
James T. Johnson wrote:
Otherwise there isn't an advantage that I can think of.
Some languages are more comfortable. When you do MC++, you don't feel as alienated from real unmanaged life as when you do C#
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
Nish - Native CPian wrote:
When you do MC++, you don't feel as alienated from real unmanaged life as when you do C#
I don't feel alienated from it because I have P/Invoke and if I really need to, I know I can just create an assembly in MC++ and do my work there.
James
|
|
|
|
|
James T. Johnson wrote:
I have P/Invoke
James T. Johnson wrote:
create an assembly in MC++
Why go to all that bother just to do C#? What's so appealing about it?
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|
|
For .NET code its a lot cleaner to me. You need to be aware of a few performance tweaks (such as avoiding unnecessary boxing) but over all the syntax is much better.
Which of these do you prefer?
MC++
ptr = *dynamic_cast<__box System::IntPtr*>(arlist->Item[index]); or this
C#
ptr = (IntPtr) arlist[index] However, the code I sent you the other day would convince me to switch to MC++ in a heart beat
James
|
|
|
|
|
James T. Johnson wrote:
However, the code I sent you the other day would convince me to switch to MC++ in a heart beat
Yeah. That was cool
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Buy it, read it and admire me
|
|
|
|