Process on CPU inside syscall


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Process on CPU inside syscall
# 8  
Old 09-06-2012
Let's suggest that we do physical read involving OS cache.
Also suggest that our cache is huge and CPU and disk are very slow that searhcing in cache consumes about 5 seconds and after that request data from disk is 10 seconds.

Code:
pread begin
  search_in_OS_cache(); << we are in searching from cache now
  
  if not_found_in_cache then
    request_from_disk();
  end if
pread end

What we will see in prstat for these thread for this 5 seconds during searching in OS cache? As I understand process state will be CPUn, right ? Will this thread be considered as blocked? As I understand now - not. Is it right?

After 5 seconds data is not found in the cache and we have to request it from disk.
So,

Code:
pread begin
  search_in_OS_cache(); 
  
  if not_found_in_cache then
    request_from_disk(); << we are here now
  end if
pread end

10 seconds we are waiting respons from disk.

What we will see in prstat for these thread for these 10 seconds? As I understand process state will be sleeping, right ? Will this thread be considered as blocked (I mean the thread a candidate for vmstat.b)? As I understand - yes. Is it right?
# 9  
Old 09-06-2012
Quote:
Originally Posted by sant
I would expect that process state will be on CPU in that moment instead of sleeping.
You'd be incorrect. System calls don't run inside the process. That's the difference between a system call and a function call... functions are just different code running inside the process, system calls are a message passed to the kernel. The process stops until the kernel starts it again.

Think of it this way. System calls are a process asking something else to do work for it. It doesn't do it itself, it hands it off to the kernel, passes a message. To pass this message, the process is automatically stopped. That's how system calls work.

Last edited by Corona688; 09-06-2012 at 01:41 AM..
# 10  
Old 09-06-2012
Quote:
Originally Posted by Corona688
You'd be incorrect. System calls don't run inside the process. That's the difference between a system call and a function call... functions are just more code running inside the process, system calls are a message passed to the kernel. The process stops until the kernel starts it again.
It is interesting.
What if I have 50 processes on the host with 100 CPU cores. And let's suggest in some moment of time ALL of them are entering in some CPU expensive syscall. As an example syscall searching data in cache. So, in this moment of time all of them in syscall.
Which state will they have in prstat? I mean exactly column STATE in prstat

---------- Post updated at 11:50 PM ---------- Previous update was at 11:44 PM ----------

Quote:
Originally Posted by Corona688
Think of it this way. System calls are a process asking something else to do work for it. It doesn't do it itself, it hands it off to the kernel, passes a message. To pass this message, the process is automatically stopped. That's how system calls work.
Yes, I am understanding your point of view. I just trying to understand which state a process has inside syscall and when it became blocked?

My understanding that
- when a process inside syscall on CPU his state in prstat is "CPUn".
- when a process inside syscall waiting response from a disk his state in prstat is "sleeping". And in the same time the process is considered as blocked. In this moment column vmstat.b will be increased.
Is it right?

So, about your point.
All consumed CPU should be recorded for some process(or thread). Let's suggest that we have IDLE system with only one running thread. This thread is entering into CPU consuming syscall. Syscall will consume about 100 hours of CPU.
Which state the thread will have in these 100 hours?
Will CPU time of the thread be increased on 100 hours?

Last edited by sant; 09-06-2012 at 02:03 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If a process cpu % is higer than

Is this possible as part of a bigger script to do? eg: elif myprocess.bin cpu% > 12 exit 1 elif is there a command for this? thanks (9 Replies)
Discussion started by: bilboNIX
9 Replies

2. Emergency UNIX and Linux Support

CPU and memory utilization of a process, by process name

Can someone please help me with a script that will help in identifying the CPU & memory usage by a process name, rather than a process id.This is to primarily analyze the consumption of resources, for performance tweaking. G (4 Replies)
Discussion started by: ggayathri
4 Replies

3. Red Hat

Process by CPU

Hello All, I am preparing a script to capture the processes consuming more CPU. So is there any way that i can sort & redirect to file only those processes consuming more than 5.0 % using ps command itself. Regards Ankit (3 Replies)
Discussion started by: ajaincv
3 Replies

4. UNIX for Dummies Questions & Answers

100% cpu process

hi guys you know we got an issue and my support line is linux I need to make sure my linux is OK...now the issue I have this process db2sysc reaching 10% CPU utilization yeah that's a DB2 process my DB guys wants to make sure linux is not the culprit but I have no idea the situation is... (3 Replies)
Discussion started by: karlochacon
3 Replies

5. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

6. AIX

CPU usage of a process

I'm trying to monitor the CPU usage of a process and output that value to a file or variable. I know topas or nmon can tell me this in interactive mode but what I need is topas-looking output that allows me to write to a file after a discrete interval. Unlike nmon data collection to a file on top... (5 Replies)
Discussion started by: robot23
5 Replies

7. Solaris

How to find which process is using up too much CPU

Hi, I need to find which processes are hogging the cpu up. please advise. Thanks (1 Reply)
Discussion started by: 0ktalmagik
1 Replies

8. UNIX for Dummies Questions & Answers

process not using enough cpu

I am running solaris 9 on a SUn 480r. It is running SAS statistical software, these processes in full flow normally run at about 50-60% cpu (theres nothing else really running on the box) this is fine, and the SAS jobs get run nice and quick. However over the last few weeks everytime a SAS job is... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

9. UNIX for Advanced & Expert Users

process -> 1 cpu

Is there a way I can assign processes to different processors? I know in windows xp you can set process affinity, and wondered if there is a *nix equivelant. (2 Replies)
Discussion started by: Solitare
2 Replies
Login or Register to Ask a Question