I have re-written a part of code in C. When testing it with logging the resource usage using getrusage(2) C API. Before changing the code: After changing: I see a lot of involuntary context switches being done in the code I have re-written. My question is not about how to reduce context switches. But.. What happens when “involuntary context switches”
Tag: unix
Program output changes when piped
I have a simple C program to time process startup (I’d rather not post the full code as it’s an active school assignment). My main function looks like this: sample_time() is a function that times how long it takes to fork a new process and returns the result in seconds as a double. The part of sample_time() that forks: As
How do I ‘skip’ minified JavaScript files while searching through a tree of js files?
I search a large js tree frequently for certain Tokens. Consider you were looking for all of the ‘.prototype’ tokens in your js files. I would do something like this: Of coarse this produces a boat-load of hits on minified vendor libs. Obscuring the real results I am after. i.e: results like that Ad nauseam. So how can I detect
Redirecting pv output to file
I’m using the pv utility to asses the speed of log entries being added in a log file, like this: This outputs the addition speed and refreshes every 5 sec: Now, I would like to redirect the current value (“10”) to a file and refresh it every 5s. Not append it, just overwrite the previous value in the file. Any
How to find the latest folder in a directory and then make a full path accordingly?
I have a directory which will have some folders and some files within it. Suppose this is my current directory as shown below with pwd command – And I am logged into machineA. This /bat/data/snapshot directory will have some folders and some files within it as shown below – So the two folders I have is 20131222 and 20131215 as
Find the sum of an infinite series
How can I find the sum of an infinite series? Series: My misbehaving example: Is it possible to carry out this method correct calculation or how to resolve this problem in other ways? Answer This series does not converge. It’s called the harmonic series and it’s known to do not converge. Moreover, as a comment says, you need to start
Equivalent lsof -i in Solaris
I have a fast question. I want to know what is the losf -i equivalent command in a Solaris system. I only want to show the files with network connection. Thank you!! Answer Here is a shell script that list all processes having open TCP or UDP ports on Solaris, you can limit it to a given port number by
How to grep a group of files within a specific time range
I’m trying to write a script used on a buffer box that does full packet capture of network traffic. As it’s for a fairly big network we split the captures into 100MB segments. At times of high network traffic oftentimes over a one minute period we will have multiple pcaps which cover that period. So what I want to do
comparing two files with different columns
i have the two files(count.txt, count1.txt). i need to do the following 1. get the values from count.txt and count1.txt where 1st column is equal. 2. if its equal need to compare the 2nd column like ((1st column value + 5) >= 2 column value) count.txt order1,150 order2,165 order3,125 count1.txt order1,155 order2,170 order3,125 order4,123 and i want the output like
netstat commands to run on unix server, what commands should I use for my use-case and why?
Sorry in advance for such a noob question, but I’m certainly a noob. My question is what does it mean to LISTEN or ACCEPT on a port as it relates to my example? EXAMPLE: I have a tomcat server, and It will use port 8080. I want to make sure that port is available for me to use. What commands