ptrace - controlling time and used memory size

P

pbartosz

I have a question about using ptrace system call.
I'm going to write a program loader that can control used memory size
and executing time.
I can use PTRACE_SINGLESTEP to control parameters after every single
instruction but in this way controlled program will execute much
slower.
Is there any other idea to overcome this problem?
 
N

Nobody

I have a question about using ptrace system call.
I'm going to write a program loader that can control used memory size
and executing time.
I can use PTRACE_SINGLESTEP to control parameters after every single
instruction but in this way controlled program will execute much
slower.
Is there any other idea to overcome this problem?

setrlimit().

RLIMIT_CPU limits the amount of CPU time.
RLIMIT_AS limits the amount of virtual memory.

You can't readily limit the amount of physical memory either via
setrlimit() (RLIMIT_RSS doesn't work in 2.6) or ptrace (physical memory
usage isn't really visible from user space).

If you want finer-grained control of virtual memory usage, you can use
PTRACE_SYSCALL to trap system calls, and intercept calls to brk() and mmap().

But as Eric suggests, you'll get better answers from a Linux (or Unix)
newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top