Sponsored Content
Full Discussion: Implementing thread in UNIX
Top Forums UNIX for Advanced & Expert Users Implementing thread in UNIX Post 302609027 by jenanee on Monday 19th of March 2012 07:36:44 AM
Old 03-19-2012
Implementing thread in UNIX

Thanks a lot for this snippet.

I tried one sample program like below:

Code:
 
#!/bin/ksh
date=`date +%y%m%d%H%M%S`
thread() {
echo "test" >> /tmp.txt
echo $date >> /tmp.txt // This to get the time logged for different iterations and see if all processed at same time
}
for i in {1..5}; do
thread &
done

In the output file - i could see the values written only for the 1st iteration but not for the subsequent iteration. Smilie
Does this mean the shell is non-POSIX compliant? or how to test whether it is POSIX compliant and whether it works for the sample script.
Does my sample program makes any sense for testing this functionality and if it is how to confirm that multi-threading is acheived using a sample script?

Last edited by fpmurphy; 03-19-2012 at 11:34 PM.. Reason: code tags please!
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cliched unix help thread

Windows blows. I'm poor so unix is looking like a great alterative (expecially after my former roommate showed me most of the things it can do). Right now I'm looking at Debian or some other Unix kernel that would run nicley on my computer. But the problem we had with installing it while he was... (3 Replies)
Discussion started by: beardsman
3 Replies

2. Forum Support Area for Unregistered Users & Account Problems

How to post a new thread (Regarding Unix related doubts) in Unix Forums

How to post a new thread (Regarding Unix related doubts) in Unix Forums. I registered my id but I am unable to post my Questions to Forum. Thanks & Regards, indusri (1 Reply)
Discussion started by: indusri
1 Replies

3. UNIX Benchmarks

unix benchmark thread?

Type: UltraSPARC IIIi 1,593 Mhz x2 Ram: 16G Disk: 2*70G fw scsi drives Load: db application kernel: Sunos5.10 pgms: compiled Sun cc -O2 ============================================================== BYTE UNIX Benchmarks (Version 3.11) System -- SunOS sun.spmbox.com 5.10... (2 Replies)
Discussion started by: mr_manny
2 Replies

4. Shell Programming and Scripting

Measure thread execution (in C, unix)

Hi, I have a simulation program which creates two threads and I would like to know if I can measure the time of each individual thread. Threads communicate (I use pthread to manage them) and I want to measure communication time. I found a solution with clock_gettime and CLOCK_THREAD_CPUTIME_ID... (32 Replies)
Discussion started by: Tinkh
32 Replies

5. Shell Programming and Scripting

Read from a file in unix(Continue from previous thread)

Hi This is continuation of previos thread status=running username=abc password=123456 server=linux The script was made which is used to capture the data from file ./scr test status It will give result running I have a case like status = running username=abc password=123456... (14 Replies)
Discussion started by: parthmittal2007
14 Replies

6. Shell Programming and Scripting

What's UNIX Expert's suggestion for this thread ?

Assume that 100 file's of type .txt are saved in directory in which, 40 .txt files having ID 225 in column x 10 .txt files having ID 220 in column x 30 .txt files having ID 115 in column x and remaining 20 .txt file's having UNIQUE ID say 226,227,228,229,230....first I want to read only files... (8 Replies)
Discussion started by: Akshay Hegde
8 Replies

7. Forum Support Area for Unregistered Users & Account Problems

UNIX.com links from Google yield invalid thread error

If one enters a Google search query like site:unix.com mysql php and clicks on the resulting link, one gets the message below: vBulletin Message No Thread specified. If you followed a valid link, please notify the administrator (2 Replies)
Discussion started by: Unregistered
2 Replies
thr_kill(3C)															      thr_kill(3C)

NAME
thr_kill - send a signal to a thread SYNOPSIS
cc -mt [ flag... ] file... [ library... ] #include <signal.h> #include <thread.h> int thr_kill(thread_t thread, int sig); The thr_kill() function sends the sig signal to the thread designated by thread. The thread argument must be a member of the same process as the calling thread. The sig argument must be one of the signals listed in signal.h(3HEAD), with the exception of SIGCANCEL being reserved and off limits to thr_kill(). If sig is 0, a validity check is done for the existence of the target thread; no signal is sent. Upon successful completion, thr_kill() returns 0. Otherwise, an error number is returned. In the event of failure, no signal is sent. The thr_kill() function will fail if: EINVAL The sig argument value is not zero and is an invalid or an unsupported signal number. ESRCH No thread was found that corresponded to the thread designated by thread ID. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ kill(2), sigaction(2), raise(3C), signal.h(3HEAD), thr_self(3C), attributes(5), standards(5) 23 Mar 2005 thr_kill(3C)
All times are GMT -4. The time now is 03:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy