1

I've written two system calls in linux, and I measure both of their resource usages with getrusage within the system call. However, most of the results I get are 0, and I'm not sure if that makes sense. Here's the output:

[ 4103.028728] DELTA RESULTS:
[ 4103.028746] u.tv_sec: 0
[ 4103.028748] s.tv_sec: 0
[ 4103.028749] u.tv_usec: 0
[ 4103.028751] s.tv_usec: 971765
[ 4103.028753] maxrss: 0
[ 4103.028755] ixrss: 0
[ 4103.028756] idrss: 0
[ 4103.028758] isrss: 0
[ 4103.028760] minflt: 0
[ 4103.028761] majflt: 0
[ 4103.028763] nswap: 0
[ 4103.028765] inblock: 0
[ 4103.028766] oublock: 0
[ 4103.028768] msgsnd: 0
[ 4103.028769] msgrcv: 0
[ 4103.028771] nsignals: 0
[ 4103.028773] nvcsw: 199
[ 4103.028774] nivcsw: 5

[ 4103.028961] CONTROL RESULTS:
[ 4103.028966] u.tv_sec: 0
[ 4103.028968] s.tv_sec: 0
[ 4103.028970] u.tv_usec: 1383
[ 4103.028972] s.tv_usec: 971998
[ 4103.028974] maxrss: 2492
[ 4103.028975] ixrss: 0
[ 4103.028977] idrss: 0
[ 4103.028978] isrss: 0
[ 4103.028980] minflt: 75
[ 4103.028982] majflt: 0
[ 4103.028984] nswap: 0
[ 4103.028986] inblock: 24
[ 4103.028987] oublock: 0
[ 4103.028989] msgsnd: 0
[ 4103.028991] msgrcv: 0
[ 4103.028992] nsignals: 0
[ 4103.028994] nvcsw: 200
[ 4103.028996] nivcsw: 5

I just want to know if this output is passable, or if it's a sign that somethings wrong, so I didn't put any of the source code. Thank you!

Ramsey Alsheikh
  • 179
  • 1
  • 1
  • 7

1 Answers1

2

This looks right; I would not expect the syscall to make any changes in the vast majority of these metrics, which are measuring resources accounted to the process, not kernel resources. You should only see a change if you make a syscall like mmap that allocates new resources to the process, or one like read that ends up storing to previously copy-on-write memory belonging to the process.

With that said, I don't think calling getrusage like this makes much sense at all. It's normally for getting aggregate usage over a process's lifetime, not measuring deltas. Some of the more esoteric things may be hard to measure deltas for in other ways, but just time (real or cpu) can be measued via clock_gettime.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
  • I don't think I'm using the delta you're talking about. The system calls were trying to run something similar to delta queuing (https://wiki.osdev.org/Blocking_Process). Sorry for the misunderstanding, and thanks for your response! – Ramsey Alsheikh Sep 01 '19 at 02:09
  • 1
    I read your question as being that these were differences before/after some syscall. Is that wrong? – R.. GitHub STOP HELPING ICE Sep 01 '19 at 02:12
  • The output is showing the difference between before two different system calls are run, and after each system call finishes. Control and Delta are two different system calls, and the output shows the resources each used while running. – Ramsey Alsheikh Sep 01 '19 at 02:15
  • 1
    What is your control syscall? – R.. GitHub STOP HELPING ICE Sep 01 '19 at 02:22
  • The control system call is a modified version of the delta system call where instead of offsetting the sleeping process it waits on each individually. Just to clear things up, my issue is that the delta system call isn't recording a lot of information, while the control does. – Ramsey Alsheikh Sep 01 '19 at 02:25