Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Threads

Reply
Thread Tools

Threads

 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      07-28-2006
Mark McIntyre <(E-Mail Removed)> wrote:

> On 27 Jul 2006 10:22:46 -0700, in comp.lang.c , "Ancient_Hacker"
> <(E-Mail Removed)> wrote:


> >Heavens, man, don't you know the C mantra: K & R worked with a 1-CPU
> >machine, and so it will be for all us descendants, for now and forever,
> >amen.


> Dork.


I would have said "troll" or "idiot", personally, but YMMV.

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
Michael Wojcik
Guest
Posts: n/a
 
      07-28-2006

In article <(E-Mail Removed)>, Keith Thompson <(E-Mail Removed)> writes:
> Mark McIntyre <(E-Mail Removed)> writes:
> > On 27 Jul 2006 10:22:46 -0700, in comp.lang.c , "Ancient_Hacker"
> > <(E-Mail Removed)> wrote:
> >>But to answer your question, you can't do that with threads, you 'll
> >>have to spin off a separate process, with fork or somesuch. Or on
> >>Unix/Linux put an ampersand on the end of the command you pass to
> >>system().

> >
> > This is completely wrong. This is how to create new /processes/ not
> > /threads/

>
> Which is exactly what he said. Re-read the above paragraph: "... you
> can't do that with threads, you 'll have to spin off a separate
> process, with fork or somesuch."


Nonetheless, the answer is still very likely wrong. It's possible
that the OP can't successfully call system() in a thread other
than the process main thread in his implementation, but how AH
came to that conclusion is unclear and suspect, since we know
nothing about the OP's implementation other than that it provides
the system function (and so is probably hosted), provides threads of
some sort, and has some abnormal exit condition that the OP refers
to as "a Segmentation Fault". (That might be a POSIX SIGSEGV, but
it might well be something else; and POSIX alone doesn't tell us
very much. OS/400 V4R3 was POSIX-compliant and UNIX-branded, IIRC.)

Oh, and that there's something called "a gtk callback" in the OP's
environment; that might be a callback function for the GNU GTK+
toolkit, say, but it might be something else entirely.

[OT] As it happens, I have just used one C implementation, plus
facilities available in the environment for that implementation,[1]
to successfully invoke the system library function in a thread other
than the program's main thread. I did not do this as any sort of
"gtk callback", but unless AH's claim was founded specifically on
this requirement, it would appear that he is, indeed, talking
rubbish.

[Further OT] The answer is suspect anyway, since AH mentions Unix,
and in Unix system is required to create a new process "as if by
fork". See SUSv3 / IEEE 1003.1-2004. Thus his answer, as written,
is nonsensical; the OP is already creating a process, if he is
using a Unix implementation.

To the OP: threads, segmentation faults, and gtk are not part of
the standard C language. You might get more helpful answers - such
as more specific redirects - if you include information about your
environment when you ask questions.

> > Please stop answering offtopic questions here, especially since you
> > don't seem to actually know the answers

>
> Yes, both threads and processes are off-topic here. They're topical
> in comp.programming.threads and comp.unix.programmer, respectively.


*Unix* processes are topical in comp.unix.programmer. We don't know
that the OP's processes are.


[1] gcc -ansi -pedantic -Wall, version 2.96, on Red Hat Linux 7.1
(Linux 2.4.7-10 #1 i686), plus pthreads from glibc-devel-2.2.4-13;
because I happened to have it handy.

--
Michael Wojcik http://www.velocityreviews.com/forums/(E-Mail Removed)

Web 2.0 is ... like talking to people - without the pesky annoyance of
other people. -- Martin Wood
 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      07-28-2006
In article <(E-Mail Removed)>,
Michael Wojcik <(E-Mail Removed)> wrote:
>OS/400 V4R3 was POSIX-compliant and UNIX-branded, IIRC.)


Unless IBM's OS/400 happens to be aka AIX 5L, it is not among the OSes
certified by the OpenGroup.

http://www.opengroup.org/openbrand/register/ibm.htm
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
 
Reply With Quote
 
Herbert Rosenau
Guest
Posts: n/a
 
      07-28-2006
On Thu, 27 Jul 2006 17:17:57 UTC, Poly-poly man
<(E-Mail Removed)> wrote:

> I'm a total newbie to threads, but am generally good with c.


C knows nothing about threads. Go and ask in a group that is for
programming (C) on your OS.


--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2 Deutsch ist da!
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      07-28-2006
On Thu, 27 Jul 2006 22:31:52 GMT, in comp.lang.c , Keith Thompson
<(E-Mail Removed)> wrote:

>Mark McIntyre <(E-Mail Removed)> writes:
>> On 27 Jul 2006 10:22:46 -0700, in comp.lang.c , "Ancient_Hacker"
>> <(E-Mail Removed)> wrote:
>>>But to answer your question, you can't do that with threads, you 'll
>>>have to spin off a separate process, with fork or somesuch. Or on
>>>Unix/Linux put an ampersand on the end of the command you pass to
>>>system().

>>
>> This is completely wrong. This is how to create new /processes/ not
>> /threads/

>
>Which is exactly what he said.


yeah, but
a) the question was about threads and
b) the OP's response made me worry that he mistook the comment from
Ancient Hacker for a solution.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 
Reply With Quote
 
av
Guest
Posts: n/a
 
      07-29-2006
On 27 Jul 2006 10:22:46 -0700, Ancient_Hacker wrote:
>Poly-poly man wrote:
>> I'm a total newbie to threads, but am generally good with c. I'm trying to


>Heavens, man, don't you know the C mantra: K & R worked with a 1-CPU
>machine, and so it will be for all us descendants, for now and forever,
>amen.
>
>Never mind that the cheapest computer at Wal-MArt will soon be a
>dual-core AMD.
>
>But to answer your question, you can't do that with threads, you 'll
>have to spin off a separate process, with fork or somesuch. Or on
>Unix/Linux put an ampersand on the end of the command you pass to
>system().


why globals are not ok in multitread enviroment?

the only right thing to do is have a copy of all global writable data
(memory space too) in each tread

 
Reply With Quote
 
Andrew Poelstra
Guest
Posts: n/a
 
      07-29-2006
On 2006-07-29, av <(E-Mail Removed)> wrote:
> why globals are not ok in multitread enviroment?
>
> the only right thing to do is have a copy of all global writable data
> (memory space too) in each tread
>


This is so off-topic that I'll take the opportunity to help you with your
grammar (I believe that you asked for help a few days ago, and no one yet
has posted for you):
1) Capitalize the first letter of a sentence.
2) Capitalize abbreviations and acronyms (OK, IMHO, etc)
3) Capitalize the word `I'.
4) End each sentence with a period.
5) Would you please end each question with a question mark?
6) Please spell all words correctly; there are online dictionaries to help
you out. (This isn't nearly as important as the others in most cases.)

--
Andrew Poelstra <website down>
To reach my email, use <email also down>
New server ETA: 42
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      07-29-2006
Andrew Poelstra wrote:
> On 2006-07-29, av <(E-Mail Removed)> wrote:
>
>>why globals are not ok in multitread enviroment?
>>
>>the only right thing to do is have a copy of all global writable data
>>(memory space too) in each tread
>>

>
>
> This is so off-topic that I'll take the opportunity to help you with your
> grammar (I believe that you asked for help a few days ago, and no one yet
> has posted for you):
> 4) End each sentence with a period.


Or a full stop

--
Ian Collins.
 
Reply With Quote
 
av
Guest
Posts: n/a
 
      07-29-2006
On Sat, 29 Jul 2006 08:36:47 +0200, av wrote:
>why globals are not ok in multitread enviroment?
>
>the only right thing to do is have a copy of all global writable data
>(memory space too) in each tread


unless there are 1 000 000 threads (and so a 1000 cpu that work all
togeter) and this could be possible in the future
 
Reply With Quote
 
Andrew Poelstra
Guest
Posts: n/a
 
      07-29-2006
On 2006-07-29, Ian Collins <(E-Mail Removed)> wrote:
> Andrew Poelstra wrote:
>> On 2006-07-29, av <(E-Mail Removed)> wrote:
>>
>>>why globals are not ok in multitread enviroment?
>>>
>>>the only right thing to do is have a copy of all global writable data
>>>(memory space too) in each tread
>>>

>>
>>
>> This is so off-topic that I'll take the opportunity to help you with your
>> grammar (I believe that you asked for help a few days ago, and no one yet
>> has posted for you):
>> 4) End each sentence with a period.

>
> Or a full stop
>


My original post did say `full stop', but I decided that that could mean
a period, a semicolon, (perhaps) a comma, a question mark, and a few
others. I decided that just saying `period' would be easier.

--
Andrew Poelstra <website down>
To reach my email, use <email also down>
New server ETA: 42
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Threads - Get running threads Pedro Pinto Java 2 04-08-2008 11:44 PM
[new to threads] threads with UI and loop Une bévue Ruby 0 06-14-2006 10:22 AM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
threads without threads sindica@gmail.com C Programming 4 08-27-2004 09:25 PM



Advertisments