source: trunk/kernel/syscalls/sys_times.c @ 93

Last change on this file since 93 was 1, checked in by alain, 8 years ago

First import

File size: 1.4 KB
Line 
1/*
2 * times.c: thread sus/usr time
3 *
4 * Copyright (c) 2015 UPMC Sorbonne Universites
5 *
6 * This file is part of ALMOS-kernel.
7 *
8 * ALMOS-kernel is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-kernel is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22
23
24#include <cpu.h>
25#include <thread.h>
26#include <time.h>
27
28int sys_times(struct tms *utms)
29{
30#ifdef CONFIG_THREAD_TIME_STAT
31        struct thread_s *this;
32        struct tms _tms;
33        error_t err;
34
35        if((utms == NULL) || NOT_IN_USPACE((uint_t)utms) || 
36                NOT_IN_USPACE((uint_t)utms+sizeof(struct tms)))
37        {
38                return EINVAL;
39        }
40
41        this = current_thread;
42
43        _tms.tms_utime = this->info.tm_usr;
44        _tms.tms_stime = this->info.tm_sys;
45        _tms.tms_cutime = 0;
46        _tms.tms_cstime = 0;
47       
48        err =  cpu_copy_to_uspace(utms, &_tms, sizeof(struct tms));
49
50        this->info.errno = err;
51        if(err) return -1;
52        return 0; 
53#else
54        this->info.errno = ENOTSUPPORTED;
55        return -1;
56
57#endif
58}
Note: See TracBrowser for help on using the repository browser.