changeset 5e0fcc528fe5 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=5e0fcc528fe5
description:
        syscall: Implementation of the times system call

diffstat:

2 files changed, 35 insertions(+)
src/kern/linux/linux.hh |   11 +++++++++++
src/sim/syscall_emul.hh |   24 ++++++++++++++++++++++++

diffs (55 lines):

diff -r 9c33426d404a -r 5e0fcc528fe5 src/kern/linux/linux.hh
--- a/src/kern/linux/linux.hh   Mon Oct 19 17:29:34 2009 -0400
+++ b/src/kern/linux/linux.hh   Sat Oct 24 10:53:57 2009 -0700
@@ -136,6 +136,17 @@
         int64_t tv_usec;        //!< microseconds
     };
 
+    /// Clock ticks per second, for times().
+    static const int _SC_CLK_TCK = 100;
+
+    /// For times().
+    struct tms {
+        int64_t tms_utime;      //!< user time
+        int64_t tms_stime;      //!< system time
+        int64_t tms_cutime;     //!< user time of children
+        int64_t tms_cstime;     //!< system time of children
+    };
+
     // For writev/readv
     struct tgt_iovec {
         uint64_t iov_base; // void *
diff -r 9c33426d404a -r 5e0fcc528fe5 src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Mon Oct 19 17:29:34 2009 -0400
+++ b/src/sim/syscall_emul.hh   Sat Oct 24 10:53:57 2009 -0700
@@ -1131,6 +1131,30 @@
     return 0;
 }
 
+/// Target times() function.
+template <class OS>
+SyscallReturn
+timesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
+           ThreadContext *tc)
+{
+    TypedBufferArg<typename OS::tms> bufp(process->getSyscallArg(tc, 0));
+
+    // Fill in the time structure (in clocks)
+    int64_t clocks = curTick * OS::_SC_CLK_TCK / Clock::Int::s;
+    bufp->tms_utime = clocks;
+    bufp->tms_stime = 0;
+    bufp->tms_cutime = 0;
+    bufp->tms_cstime = 0;
+
+    // Convert to host endianness
+    bufp->tms_utime = htog(bufp->tms_utime);
+
+    // Write back
+    bufp.copyOut(tc->getMemPort());
+
+    // Return clock ticks since system boot
+    return clocks;
+}
 
 
 
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to