Jiaojinxing
10 years ago
4 changed files with 101 additions and 10 deletions
@ -0,0 +1,38 @@ |
|||
/**
|
|||
* @file |
|||
* CPU library header. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#ifndef __VXWORKS_VXCPULIB_H |
|||
#define __VXWORKS_VXCPULIB_H |
|||
|
|||
#include "vxWorksCommon.h" |
|||
#include <sched.h> |
|||
|
|||
/*
|
|||
* CPU set |
|||
*/ |
|||
typedef cpu_set_t cpuset_t; |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C" { |
|||
#endif |
|||
|
|||
/* function declarations */ |
|||
|
|||
unsigned int vxCpuIndexGet(void); |
|||
cpuset_t vxCpuEnabledGet(void); |
|||
unsigned int vxCpuConfiguredGet(void); |
|||
|
|||
#ifdef __cplusplus |
|||
} |
|||
#endif |
|||
|
|||
#endif /* __VXWORKS_VXCPULIB_H */ |
@ -0,0 +1,54 @@ |
|||
/**
|
|||
* @file |
|||
* CPU library. |
|||
* |
|||
* VxWork compatibility layer in SylixOS. |
|||
* |
|||
* Copyright (c) 2001-2014 SylixOS Group. |
|||
* All rights reserved. |
|||
* |
|||
* Author: Han.hui <sylixos@gmail.com> |
|||
*/ |
|||
|
|||
#define __SYLIXOS_KERNEL |
|||
#include <unistd.h> |
|||
#include "vxCpuLib.h" |
|||
|
|||
/*
|
|||
* get current CPU index. |
|||
*/ |
|||
unsigned int vxCpuIndexGet (void) |
|||
{ |
|||
INTREG ireg; |
|||
ULONG id; |
|||
|
|||
API_InterLock(&ireg); |
|||
id = LW_CPU_GET_CUR_ID(); |
|||
API_InterUnlock(ireg); |
|||
|
|||
return ((unsigned int)id); |
|||
} |
|||
|
|||
/*
|
|||
* get enable CPU index. |
|||
*/ |
|||
cpuset_t vxCpuEnabledGet (void) |
|||
{ |
|||
static cpuset_t set; |
|||
|
|||
sched_getaffinity(getpid(), sizeof(set), &set); |
|||
|
|||
return (set); |
|||
} |
|||
|
|||
/*
|
|||
* get CPU count. |
|||
*/ |
|||
unsigned int vxCpuConfiguredGet (void) |
|||
{ |
|||
return ((unsigned int)sysconf(_SC_NPROCESSORS_CONF)); |
|||
} |
|||
|
|||
/*
|
|||
* end |
|||
*/ |
Loading…
Reference in new issue