Sponsored Content
Top Forums Shell Programming and Scripting Need help in column comparison & adding extra line to files Post 302734749 by b@l@ji on Thursday 22nd of November 2012 03:36:47 PM
Old 11-22-2012
@ Don Cragun: As you can see that , I have amended the post with the existing code which I use.

Can you throw your expert opinion on how further the script can be handled efficiently ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in adding positive & negative values in a column

Hi Gurus, In my file I have an amount field from position 74 to 87, which contains values starting with '+' as well as '-'. I want to add all positive values in a varible called "CREDIT" and all negative values in a variable "DEBIT". I know, we can use grep to identify values with positive and... (4 Replies)
Discussion started by: berlin_germany
4 Replies

2. IP Networking

Adding an extra route to the ip routing table

In my college dorm, there is a file sharing network in the entire building. Problem is, there is only a manual for windows with the settings on how to connect... :mad: They say that you have to give the following command in cmd in windows: route add 172.16.71.0 mask 255.255.255.0... (2 Replies)
Discussion started by: Japie89
2 Replies

3. Shell Programming and Scripting

Column comparison between two files: moved from another post

I have two files as follows: Pval.txt ID Pvalue 91500 0.004 91700 0.007 91800 0.12 91900 0.05 92000 0.99 Freq.txt ID Frequency 90000 56 91500 29 91600 78 91700 60 91800 77 91900 66 92000 70 92100 50 92200 60I need to compare 1st... (19 Replies)
Discussion started by: cs_novice
19 Replies

4. Solaris

Adding Extra Hard Disk

Hi Solaris users - I have an Ultra10 SPARC machine, with IIe processor. To prepare for the Solaris10 admin exam PartII I need to set up the metadb/mirroring in my machine, but do not know how to do this properly. I need this to practice the mirroring tasks. If anyone could help it would be... (3 Replies)
Discussion started by: patcom
3 Replies

5. Shell Programming and Scripting

adding a column of unique string to multiple files

Hi, I need to add a column of unique string to individual csv file. my individual csv file looks like this and each file has variable row length: 178.52,39.4,train,0.003355544375334351,39.15752753933254,0.4895933968953914... (7 Replies)
Discussion started by: ida1215
7 Replies

6. Shell Programming and Scripting

Faster Line by Line String/Date Comparison of 2 Files

Hello, I was wondering if anyone knows a faster way to search and compare strings and dates from 2 files? I'm currently using "for loop" but seems sluggish as i have to cycle through 10 directories with 10 files each containing thousands of lines. Given: -10 directories -10 files... (4 Replies)
Discussion started by: agentgrecko
4 Replies

7. Shell Programming and Scripting

Merge two files line by line and column by column

Hi All, I have two files having oracle query result. I want to merge to files line by line and also with column File1 23577|SYNC TYPE 23578|Order Number|ConnectionState 23585|Service State|Service NameFile2 23577|AR Alarm Sync 23578|A5499|9 23585|7|test_nov7Result... (18 Replies)
Discussion started by: Harshal22
18 Replies

8. Shell Programming and Scripting

Adding Extra Column in txt file base on Condition

HI Guys, I have below input. Output Base on Below Condition. 1> if forth column is empty and next coming line have same name with \es then add that column name on all rows 2>rest of all are es:vsDataEUtranCellFDD Input:- CCL01736 CCL01736_7A_1 es:vsDataEUtranCellFDD ... (3 Replies)
Discussion started by: pareshkp
3 Replies

9. Shell Programming and Scripting

awk - 2 files comparison without for loop - multi-line issue

Greetings Experts, I need to handle the views created over monthly retention tables for which every new table in YYYYMMDD format, there is equivalent view created and the older table which might be dropped, the view over it has to be re-created over a dummy table so that it doesn't fail.... (2 Replies)
Discussion started by: chill3chee
2 Replies

10. Shell Programming and Scripting

Adding an extra date column in UNIX file

Hi All, I have a file with only one column of data (without delimiter). For Ex: cat temp.txt 22055 21088 93840 30990 50990 50950 I want to insert an additional column with current date as value. So, i have used below command but didn't get the result as excepted. Could onyone over... (5 Replies)
Discussion started by: Suresh
5 Replies
tpool(3tcl)															       tpool(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
tpool - Part of the Tcl threading extension implementing pools of worker threads. SYNOPSIS
package require Tcl 8.4 package require Thread ?2.6? tpool::create ?options? tpool::names tpool::post ?-detached? ?-nowait? tpool script tpool::wait tpool joblist ?varname? tpool::cancel tpool joblist ?varname? tpool::get tpool job tpool::preserve tpool tpool::release tpool _________________________________________________________________ DESCRIPTION
This package creates and manages pools of worker threads. It allows you to post jobs to worker threads and wait for their completion. The threadpool implementation is Tcl event-loop aware. That means that any time a caller is forced to wait for an event (job being completed or a worker thread becoming idle or initialized), the implementation will enter the event loop and allow for servicing of other pending file or timer (or any other supported) events. COMMANDS
tpool::create ?options? This command creates new threadpool. It accepts several options as key-value pairs. Options are used to tune some threadpool parame- ters. The command returns the ID of the newly created threadpool. Following options are supported: -minworkers number Minimum number of worker threads needed for this threadpool instance. During threadpool creation, the implementation will create somany worker threads upfront and will keep at least number of them alive during the lifetime of the threadpool instance. Default value of this parameter is 0 (zero). which means that a newly threadpool will have no worker threads ini- tialy. All worker threads will be started on demand by callers running tpool::post command and posting jobs to the job queue. -maxworkers number Maximum number of worker threads allowed for this threadpool instance. If a new job is pending and there are no idle worker threads available, the implementation will try to create new worker thread. If the number of available worker threads is lower than the given number, new worker thread will start. The caller will automatically enter the event loop and wait until the worker thread has initialized. If. however, the number of available worker threads is equal to the given number, the caller will enter the event loop and wait for the first worker thread to get idle, thus ready to run the job. Default value of this parameter is 4 (four), which means that the threadpool instance will allow maximum of 4 worker threads running jobs or being idle waiting for new jobs to get posted to the job queue. -idletime seconds Time in seconds an idle worker thread waits for the job to get posted to the job queue. If no job arrives during this inter- val and the time expires, the worker thread will check the number of currently available worker threads and if the number is higher than the number set by the minthreads option, it will exit. If an exitscript has been defined, the exiting worker thread will first run the script and then exit. Errors from the exit script, if any, are ignored. The idle worker thread is not servicing the event loop. If you, however, put the worker thread into the event loop, by evalu- ating the vwait or other related Tcl commands, the worker thread will not be in the idle state, hence the idle timer will not be taken into account. Default value for this option is unspecified, hence, the Tcl interpreter of the worker thread will contain just the initial set of Tcl commands. -initcmd script Sets a Tcl script used to initialize new worker thread. This is usually used to load packages and commands in the worker, set default variables, create namespaces, and such. If the passed script runs into a Tcl error, the worker will not be created and the initiating command (either the tpool::create or tpool::post) will throw error. Default value for this option is unspecified, hence, the Tcl interpreter of the worker thread will contain just the initial set of Tcl commands. -exitcmd script Sets a Tcl script run when the idle worker thread exits. This is normaly used to cleanup the state of the worker thread, release reserved resources, cleanup memory and such. Default value for this option is unspecified, thus no Tcl script will run on the worker thread exit. tpool::names This command returns a list of IDs of threadpools created with the tpool::create command. If no threadpools were found, the command will return empty list. tpool::post ?-detached? ?-nowait? tpool script This command sends a script to the target tpool threadpool for execution. The script will be executed in the first available idle worker thread. If there are no idle worker threads available, the command will create new one, enter the event loop and service events until the newly created thread is initialized. If the current number of worker threads is equal to the maximum number of worker threads, as defined during the threadpool creation, the command will enter the event loop and service events while waiting for one of the worker threads to become idle. If the optional ?-nowait? argument is given, the command will not wait for one idle worker. It will just place the job in the pool's job queue and return immediately. The command returns the ID of the posted job. This ID is used for subsequent tpool::wait, tpool::get and tpool::cancel commands to wait for and retrieve result of the posted script, or cancel the posted job respectively. If the optional ?-detached? argument is specified, the command will post a detached job. A detached job can not be cancelled or waited upon and is not identified by the job ID. If the threadpool tpool is not found in the list of active thread pools, the command will throw error. The error will also be trig- gered if the newly created worker thread fails to initialize. tpool::wait tpool joblist ?varname? This command waits for one or many jobs, whose job IDs are given in the joblist to get processed by the worker thread(s). If none of the specified jobs are ready, the command will enter the event loop, service events and wait for the first job to get ready. The command returns the list of completed job IDs. If the optional variable ?varname? is given, it will be set to the list of jobs in the joblist which are still pending. If the threadpool tpool is not found in the list of active thread pools, the command will throw error. tpool::cancel tpool joblist ?varname? This command cancels the previously posted jobs given by the joblist to the pool tpool. Job cancellation succeeds only for job still waiting to be processed. If the job is already being executed by one of the worker threads, the job will not be cancelled. The com- mand returns the list of cancelled job IDs. If the optional variable ?varname? is given, it will be set to the list of jobs in the joblist which were not cancelled. If the threadpool tpool is not found in the list of active thread pools, the command will throw error. tpool::get tpool job This command retrieves the result of the previously posted job. Only results of jobs waited upon with the tpool::wait command can be retrieved. If the execution of the script resulted in error, the command will throw the error and update the errorInfo and error- Code variables correspondingly. If the pool tpool is not found in the list of threadpools, the command will throw error. If the job job is not ready for retrieval, because it is currently being executed by the worker thread, the command will throw error. tpool::preserve tpool Each call to this command increments the reference counter of the threadpool tpool by one(1). Command returns the value of the ref- erence counter after the increment. By incrementing the reference counter, the caller signalizes that he/she wishes to use the resource for a longer period of time. tpool::release tpool Each call to this command decrements the reference counter of the threadpool tpool by one(1).Command returns the value of the ref- erence counter after the decrement. When the reference counter reaches zero(0), the threadpool tpool is marked for termination. You should not reference the threadpool after the tpool::release command returns zero. The tpool handle goes out of scope and should not be used any more. Any following reference to the same threadpool handle will result in Tcl error. DISCUSSION
Threadpool is one of the most common threading paradigm when it comes to server applications handling a large number of relatively small tasks. A very simplistic model for building a server application would be to create a new thread each time a request arrives and service the request in the new thread. One of the disadvantages of this approach is that the overhead of creating a new thread for each request is significant; a server that created a new thread for each request would spend more time and consume more system resources in creating and destroying threads than in processing actual user requests. In addition to the overhead of creating and destroying threads, active threads consume system resources. Creating too many threads can cause the system to run out of memory or trash due to excessive memory consump- tion. A thread pool offers a solution to both the problem of thread life-cycle overhead and the problem of resource trashing. By reusing threads for multiple tasks, the thread-creation overhead is spread over many tasks. As a bonus, because the thread already exists when a request arrives, the delay introduced by thread creation is eliminated. Thus, the request can be serviced immediately. Furthermore, by properly tuning the number of threads in the thread pool, resource thrashing may also be eliminated by forcing any request to wait until a thread is available to process it. SEE ALSO
thread, tsv, ttrace KEYWORDS
thread, threadpool Tcl Threading 2.6 tpool(3tcl)
All times are GMT -4. The time now is 08:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy