04-14-2009
Code tags for code please, [ code ] stuff [ /code ] without the extra spaces in the tags.
What have you been trying? What precisely is multithreading supposed to do here?
9 More Discussions You Might Find Interesting
1. Programming
Hello,
I would like get idea about performance enginering from basic to advanced level. Do anyone know a place where i can find some videos related to performance engineering ? (5 Replies)
Discussion started by: shafi2all
5 Replies
2. Solaris
can anyone explain me the RAID concepts clearly. I studied some book bt i didnt get any clear idea. (4 Replies)
Discussion started by: rogerben
4 Replies
3. UNIX for Advanced & Expert Users
I write kernel module with kernel threads using
linux/kthread.h on 2.6.* kernel
I tried to passing data between two kernel threads
with data argument of kthread_run( fun, data , NAME );
but this is not work I dont know why. I tried many possibility
and nothing works.
So I thought that... (0 Replies)
Discussion started by: marcintom
0 Replies
4. Programming
hi
plz help me modifying the following code (use pcap) to include concepts of parallel programming or multi threading. I am trying from the past 1 week to change the code and apply concepts of threads but have been unsuccessful.. pls guide me..
/* This section contains additional information... (1 Reply)
Discussion started by: aka.bhagvanji
1 Replies
5. Shell Programming and Scripting
Hi,
How to use the return code, for parallel running threads.
Ex-
grep pattern1 file1 file2 file3 file4 &
grep pattern1 file5 file6 file7 file8 &
grep pattern1 file9 file10 file11 file12 &
return_code=$?
if (return_code -eq 0)
then
echo "pattern found"
else
echo... (2 Replies)
Discussion started by: jitendriya.dash
2 Replies
6. IP Networking
Hi,
1)i wrote a program which acts lik a client gateway serving clients request and sending probe msg`s to server to chech if its active..
2)both moduels interact when run independently my problem is that when i tr to run them as two different threads in a single program(client_gateway prog to... (4 Replies)
Discussion started by: sameer kulkarni
4 Replies
7. Programming
Hi , i am very new to threads.. need help to build the following program.
Please if possible provide me the program.
The program should be in C language working in Linux operating systems.
Q) Execute a program using any thread library to create the number of threads specified by the user; each... (2 Replies)
Discussion started by: rajeshgauns
2 Replies
8. UNIX for Dummies Questions & Answers
Team,
I am working in unix perl . i have come across scenarios where there are lots of unix concepts are being used.
For example, Handle, pipes, forking ,data sharing between processes,parallel processing and so on. I need some conceptual explanation about the unix system .
I... (5 Replies)
Discussion started by: mdsaleemj
5 Replies
9. High Performance Computing
I am looking to have a C++ and Python application developed using the processing power of at least one GPU.
We are already using Boost, so Boost.MPI comes to mind.
We already have some experience in developing C++ applications for multi-core CPUs by using threading.
However, since we have not... (3 Replies)
Discussion started by: figaro
3 Replies
LEARN ABOUT DEBIAN
ns_thread
ns_thread(3aolserver) AOLserver Built-In Commands ns_thread(3aolserver)
__________________________________________________________________________________________________________________________________________________
NAME
ns_thread - commands
SYNOPSIS
ns_thread begin script
ns_thread begindetached script
ns_thread get
ns_thread getid
ns_thread wait tid
ns_thread yield
_________________________________________________________________
DESCRIPTION
ns_thread begin:
begins a new thread which evaluates the specified script and then exits. It returns a thread ID that must eventually be passed to
ns_thread wait. (Failing to call ns_thread wait will eventually result in no new threads being created.)
ns_thread begindetached:
begins a detached thread that doesn't have to be (and can't be) waited for.
ns_thread get:
gets the thread ID of the current thread. The result is a thread ID that can be passed to ns_thread wait and may look something like
"tid532".
ns_thread getid:
gets the thread integer number for the current thread. The result is a small integer used for identifying threads is a human-read-
able way, such as "1" or "1120", for example.
ns_thread wait:
waits for the specified thread to exit. The tid argument is a thread ID returned by ns_thread begin or ns_thread get.
ns_thread yield:
causes the current thread to yield.
EXAMPLES
This example is similar to the example under the ns_sockselect function of connecting to the 10 servers and waiting to service them with
the ns_sockselect command. In this case, though, each connection gets it's own thread.
# This is the procedure which is evaluated for each thread and # handles a single connection to host number $i
proc getpage {i} {
global pages
# new thread will start here - first connect to host
set host [format "www%2d.foo.com" $i]
set fds [ns_sockopen $host 80
set r [lindex $fds 0]
set w [lindex $fds 1]
# next, send request 0r"
puts $w "GET /index.htm HTTP/1.0
flush $w
# then read page
set pages($i) [read $r]
# and close sockets
close $w
close $r
# thread goes away here and other threads waiting
# on ns_thread wait will wakeup }
# Here's the loop which creates the threads which run getpage. for {set i 1} {$i < 9} {incr i} {
set tids($i) [ns_thread begin "getpage $i"] }
# wait for the threads to exit and then process the pages for {set i 1} {$i < 9} {incr i} {
ns_thread wait $tids($i)
# output page
... process the page in $pages($i) put there by other thread ... }
Note that the code here is much simpler to follow than the ns_sockselect example; that's the benefit of multithreaded programming. However,
it uses more resources as threads need to be created and initialized. This can be a problem if you plan to create many threads.
SEE ALSO
KEYWORDS
threads
AOLserver 4.0 ns_thread(3aolserver)