question regarding multithreading and malloc() requests


 
Thread Tools Search this Thread
Top Forums Programming question regarding multithreading and malloc() requests
# 8  
Old 03-10-2008
Quote:
Originally Posted by ramen_noodle
By definition a stack is LIFO, right?
Yes. For example say you call a bunch of functions or sub-routines in a c-program, they would appear on the call stack in the following order (where function2() is the most recent function to be called, function1() was called before function2() etc... )

Code:
 function2()
 
 function1()

  main()

Please let me know if that helps in anyway
# 9  
Old 03-11-2008
Quote:
Originally Posted by JamesGoh
Yes. For example say you call a bunch of functions or sub-routines in a c-program, they would appear on the call stack in the following order (where function2() is the most recent function to be called, function1() was called before function2() etc... )

Code:
 function2()
 
 function1()

  main()

Please let me know if that helps in anyway
You are absolutely correct.
A main is also a thread; they way it has a calling sequence to a function, the way a posix thread calls to functions look like.

Ramen: Can't we call epoll()/kqueue() in the threads; why to call in the main thread (in the hi-performing server apps -as you have said) even in the asynchronous nonblocking calls?? I know kqueue() a bit but still not much can we discuss this in the rest of the thread?
# 10  
Old 03-11-2008
thanks Praveen
# 11  
Old 03-12-2008
Praveen: As you yourself noted the utilization of whatever event servicing mechanism you use is going to execute in a thread. Soo I don't think that your question is ingenuous.

My point was that if you service a client with a separate thread you will run out of resources pretty quickly given a sufficiently complex interaction and number of clients.
With asynchronous service and a single thread you do not incur the memory overhead of separate threads and stack space for each.
# 12  
Old 03-12-2008
Quote:
Originally Posted by ramen_noodle
Praveen: As you yourself noted the utilization of whatever event servicing mechanism you use is going to execute in a thread. Soo I don't think that your question is ingenuous.

My point was that if you service a client with a separate thread you will run out of resources pretty quickly given a sufficiently complex interaction and number of clients.
With asynchronous service and a single thread you do not incur the memory overhead of separate threads and stack space for each.
Frankly Ramen, I never got a chance to use epoll()/kqueue(). I've only been able to use select()/poll() for such event notification machanism, at least in the commercial projects, we've worked on. I also wanted the discussion to be carried further on event notification machanisms so that we get benefited along with many others in the forum and kqueue()/epoll() are good candidates to be discussed. Pl don't take otherwise.

Still may we discuss them further on which Unix/Unix Like platforms support it apart from Linux/BSD (which I've only worked so far)?
# 13  
Old 03-12-2008
Praveen:
Your use of select and poll in commercial (I'm reading as designedly portable software to various unixes) is understandable. epoll and kqueue are, after all, linux/*bsd specific.

Still pselect/select and poll are perfectly good event interfaces after all.
epoll seems to have a superior interface to select/poll with the notable absence of signal processing ala pselect.

I haven't worked with kqueue but am familiar with the interface from reading 'The Design and Implementation of The FreeBSD Operating System'.
.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Help with multithreading

I take this question of the The Linux Programming Interface: A Linux and Unix System Programming page 652 exercise 30.1 I want someone to explain the under line statement because it sounds complex to me couldn't understand anything 30-1 Modify the program (thread_incr.c) so that each loop in... (3 Replies)
Discussion started by: fwrlfo
3 Replies

2. What is on Your Mind?

Alarm interrupt and multithreading

Hi Friends any know how became a friend in this Android Programming Language (0 Replies)
Discussion started by: ljarun
0 Replies

3. Programming

how to do udp broadcast with multithreading

hello to all i want to use multithreading to my UDP broadcast server client program. will anyone help me by proving C code. i am working in fedora. also my requirement is POSIX compliance.please help me..... (6 Replies)
Discussion started by: moti12
6 Replies

4. IP Networking

how to do udp broadcast with multithreading

hello to all i want to use multithreading to my UDP broadcast server client program. will anyone help me by proving C code. i am working in fedora. also my requirement is POSIX compliance.please help me..... (0 Replies)
Discussion started by: moti12
0 Replies

5. Programming

MultiThreading using Pthreads

Situation: i have multiple pthread_create calls like this: pthread_create(...., ThreadFunc1,.....); pthread_create(...., ThreadFunc2,.....); . . which i am using to create multiple threads.All the "ThreadFunc<i>" functions are actually calling same function "Receive" of a class using same... (3 Replies)
Discussion started by: Sastra
3 Replies

6. Shell Programming and Scripting

Multithreading program

Hi I need to insert 1million records into MySQL database, but it is taking lot of time as there is no bulk insert support. I want to spawn 10 processes which will insert 100k records each parallely. Can somebody help me with a example program to execute this task through shell scripting. (5 Replies)
Discussion started by: sach_roger
5 Replies

7. UNIX for Advanced & Expert Users

multithreading in UNIX

Hi, Can you please give me a suitable reference to learn multithreading programming in C in UNIX? Thanks (3 Replies)
Discussion started by: naan
3 Replies

8. Programming

multithreading on OSX

Hi all, I have a query about multithreading. What I would like to do is, at the start of my main update() function, start a couple of threads in parallel, once they are all complete carry on with my main update function. void update() { thread1->update(); // fluid solver ... (3 Replies)
Discussion started by: memoid
3 Replies

9. Programming

Multithreading in Pro*C

:confused: Hi! I have created a Multhreaded Application in Pro*C (using pthreads) with about 5 Threads running simultaneously. The Application is basically to Update a Centralized Table in Oracle, which updates different rows in the Table (Each Thread updates different rows!). The... (16 Replies)
Discussion started by: shaik786
16 Replies
Login or Register to Ask a Question