summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2019-04-05 08:16:05 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-04-09 08:06:46 +0200
commitf9219db2a95c8285d1be22092572b4236bfe6488 (patch)
treec168ac7fdf7458cea6d7146584b2adb38d47f6a1 /cpukit
parentrtems: Add rtems_scheduler_get_processor() (diff)
downloadrtems-f9219db2a95c8285d1be22092572b4236bfe6488.tar.bz2
rtems: Add rtems_scheduler_get_processor_maximum()
Add rtems_scheduler_get_processor_maximum() as a replacement for rtems_get_processor_count(). The rtems_get_processor_count() is a bit orphaned. Adopt it by the Scheduler Manager. The count is also misleading, since the processor set may have gaps and the actual count of online processors may be less than the value returned by rtems_get_processor_count(). Update #3732.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/headers.am1
-rw-r--r--cpukit/include/rtems.h1
-rw-r--r--cpukit/include/rtems/rtems/smp.h59
-rw-r--r--cpukit/include/rtems/rtems/tasks.h33
-rw-r--r--cpukit/libmisc/capture/capture.c6
-rw-r--r--cpukit/libmisc/capture/capture_support.c2
-rw-r--r--cpukit/libmisc/cpuuse/cpuusagereset.c2
-rw-r--r--cpukit/libmisc/stackchk/check.c2
-rw-r--r--cpukit/libtest/t-test-rtems-measure.c2
-rw-r--r--cpukit/libtest/testparallel.c6
-rw-r--r--cpukit/libtrace/record/record-server.c2
-rw-r--r--cpukit/posix/src/sysconf.c2
-rw-r--r--cpukit/rtems/src/getprocessorcount.c4
-rw-r--r--cpukit/sapi/src/profilingiterate.c2
14 files changed, 48 insertions, 76 deletions
diff --git a/cpukit/headers.am b/cpukit/headers.am
index 69cdb525ef..c9fe38acf3 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -274,7 +274,6 @@ include_rtems_rtems_HEADERS += include/rtems/rtems/semmp.h
include_rtems_rtems_HEADERS += include/rtems/rtems/signal.h
include_rtems_rtems_HEADERS += include/rtems/rtems/signalimpl.h
include_rtems_rtems_HEADERS += include/rtems/rtems/signalmp.h
-include_rtems_rtems_HEADERS += include/rtems/rtems/smp.h
include_rtems_rtems_HEADERS += include/rtems/rtems/status.h
include_rtems_rtems_HEADERS += include/rtems/rtems/statusimpl.h
include_rtems_rtems_HEADERS += include/rtems/rtems/support.h
diff --git a/cpukit/include/rtems.h b/cpukit/include/rtems.h
index 20a1705dc5..9f6f9cc659 100644
--- a/cpukit/include/rtems.h
+++ b/cpukit/include/rtems.h
@@ -55,7 +55,6 @@
#if defined(RTEMS_MULTIPROCESSING)
#include <rtems/rtems/mp.h>
#endif
-#include <rtems/rtems/smp.h>
#include <rtems/rtems/support.h>
#include <rtems/score/stack.h>
diff --git a/cpukit/include/rtems/rtems/smp.h b/cpukit/include/rtems/rtems/smp.h
deleted file mode 100644
index 046c306290..0000000000
--- a/cpukit/include/rtems/rtems/smp.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * @file
- *
- * @ingroup ClassicSMP
- *
- * @brief SMP Services API
- */
-
-/*
- * COPYRIGHT (c) 1989-2011.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifndef _RTEMS_RTEMS_SMP_H
-#define _RTEMS_RTEMS_SMP_H
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @defgroup ClassicSMP SMP Services
- *
- * @ingroup RTEMSAPIClassic
- *
- * This encapsulates functionality which is useful for SMP applications.
- *
- * @{
- */
-
-/**
- * @brief Returns the count of processors in the system.
- *
- * On uni-processor configurations a value of one will be returned.
- *
- * On SMP configurations this returns the value of a global variable set during
- * system initialization to indicate the count of utilized processors. The
- * processor count depends on the physically or virtually available processors
- * and application configuration. The value will always be less than or equal
- * to the maximum count of application configured processors.
- *
- * @return The count of processors being utilized.
- */
-uint32_t rtems_get_processor_count(void);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-/* end of include file */
diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h
index 630a5c5295..307b1b13aa 100644
--- a/cpukit/include/rtems/rtems/tasks.h
+++ b/cpukit/include/rtems/rtems/tasks.h
@@ -618,6 +618,39 @@ rtems_get_current_processor( void )
}
/**
+ * @brief Returns the processor maximum supported by the system.
+ *
+ * In uniprocessor configurations, a value of one will be returned.
+ *
+ * In SMP configurations, this function returns the minimum of the processors
+ * (physically or virtually) available by the platform and the configured
+ * processor maximum. Not all processors in the range from processor index
+ * zero to the last processor index (which is the processor maximum minus one)
+ * may be configured to be used by a scheduler or online (online processors
+ * have a scheduler assigned).
+ *
+ * @return The processor maximum supported by the system.
+ *
+ * @see rtems_scheduler_add_processor() and rtems_scheduler_remove_processor().
+ */
+RTEMS_CONST uint32_t rtems_scheduler_get_processor_maximum( void );
+
+/**
+ * @brief Returns the processor maximum supported by the system.
+ *
+ * @return The processor maximum supported by the system.
+ *
+ * @deprecated
+ *
+ * Use rtems_scheduler_get_processor_maximum() instead.
+ */
+RTEMS_DEPRECATED RTEMS_INLINE_ROUTINE uint32_t
+rtems_get_processor_count( void )
+{
+ return rtems_scheduler_get_processor_maximum();
+}
+
+/**
* @brief Gets the set of processors owned by the specified scheduler instance.
*
* @param[in] scheduler_id Identifier of the scheduler instance.
diff --git a/cpukit/libmisc/capture/capture.c b/cpukit/libmisc/capture/capture.c
index 6accd509e7..bba7d91396 100644
--- a/cpukit/libmisc/capture/capture.c
+++ b/cpukit/libmisc/capture/capture.c
@@ -599,7 +599,7 @@ rtems_capture_open (uint32_t size, rtems_capture_timestamp timestamp RTEMS_UNU
return RTEMS_RESOURCE_IN_USE;
}
- count = rtems_get_processor_count();
+ count = rtems_scheduler_get_processor_maximum();
if (capture_per_cpu == NULL) {
capture_per_cpu = calloc( count, sizeof( *capture_per_cpu ) );
}
@@ -686,7 +686,7 @@ rtems_capture_close (void)
}
capture_controls = NULL;
- for (cpu=0; cpu < rtems_get_processor_count(); cpu++) {
+ for (cpu=0; cpu < rtems_scheduler_get_processor_maximum(); cpu++) {
if (capture_records_on_cpu(cpu).buffer)
rtems_capture_buffer_destroy( &capture_records_on_cpu(cpu) );
@@ -788,7 +788,7 @@ rtems_capture_flush (bool prime)
else
capture_flags_global &= ~RTEMS_CAPTURE_OVERFLOW;
- for (cpu=0; cpu < rtems_get_processor_count(); cpu++) {
+ for (cpu=0; cpu < rtems_scheduler_get_processor_maximum(); cpu++) {
RTEMS_INTERRUPT_LOCK_REFERENCE( lock, &(capture_lock_on_cpu( cpu )) )
rtems_interrupt_lock_context lock_context_per_cpu;
diff --git a/cpukit/libmisc/capture/capture_support.c b/cpukit/libmisc/capture/capture_support.c
index 60006e7dd8..4af8822c79 100644
--- a/cpukit/libmisc/capture/capture_support.c
+++ b/cpukit/libmisc/capture/capture_support.c
@@ -268,7 +268,7 @@ rtems_capture_print_trace_records (int total, bool csv)
rtems_capture_time last_time = 0;
int i;
- cpus = rtems_get_processor_count ();
+ cpus = rtems_scheduler_get_processor_maximum ();
per_cpu = calloc (cpus, sizeof(*per_cpu));
if (per_cpu == NULL)
diff --git a/cpukit/libmisc/cpuuse/cpuusagereset.c b/cpukit/libmisc/cpuuse/cpuusagereset.c
index 507044a7ee..455651e19f 100644
--- a/cpukit/libmisc/cpuuse/cpuusagereset.c
+++ b/cpukit/libmisc/cpuuse/cpuusagereset.c
@@ -56,7 +56,7 @@ void rtems_cpu_usage_reset( void )
_TOD_Get_uptime( &CPU_usage_Uptime_at_last_reset );
- cpu_count = rtems_get_processor_count();
+ cpu_count = rtems_scheduler_get_processor_maximum();
for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
index ce7d1a08cb..a3f9a1d21e 100644
--- a/cpukit/libmisc/stackchk/check.c
+++ b/cpukit/libmisc/stackchk/check.c
@@ -477,7 +477,7 @@ void rtems_stack_checker_report_usage_with_plugin(
RTEMS_DECONST( rtems_printer *, printer )
);
- cpu_max = rtems_get_processor_count();
+ cpu_max = rtems_scheduler_get_processor_maximum();
for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
Stack_check_Dump_interrupt_stack_usage(
diff --git a/cpukit/libtest/t-test-rtems-measure.c b/cpukit/libtest/t-test-rtems-measure.c
index 242855f19f..80b404f1ad 100644
--- a/cpukit/libtest/t-test-rtems-measure.c
+++ b/cpukit/libtest/t-test-rtems-measure.c
@@ -200,7 +200,7 @@ T_measure_runtime_create(const T_measure_runtime_config *config)
chunk_size *= 2;
- load_count = rtems_get_processor_count();
+ load_count = rtems_scheduler_get_processor_maximum();
load_size = load_count * sizeof(ctx->load_contexts[0]);
ctx = malloc(sizeof(*ctx) + sample_size + load_size + chunk_size +
diff --git a/cpukit/libtest/testparallel.c b/cpukit/libtest/testparallel.c
index ea805a3cf4..4ff26650f5 100644
--- a/cpukit/libtest/testparallel.c
+++ b/cpukit/libtest/testparallel.c
@@ -60,8 +60,8 @@ static void run_tests(
for (i = 0; i < job_count; ++i) {
const rtems_test_parallel_job *job = &jobs[i];
- size_t n = rtems_get_processor_count();
- size_t j = job->cascade ? 0 : rtems_get_processor_count() - 1;
+ size_t n = rtems_scheduler_get_processor_maximum();
+ size_t j = job->cascade ? 0 : rtems_scheduler_get_processor_maximum() - 1;
while (j < n) {
size_t active_worker = j + 1;
@@ -133,7 +133,7 @@ void rtems_test_parallel(
_Atomic_Init_ulong(&ctx->stop, 0);
_SMP_barrier_Control_initialize(&ctx->barrier);
- ctx->worker_count = rtems_get_processor_count();
+ ctx->worker_count = rtems_scheduler_get_processor_maximum();
ctx->worker_ids[0] = rtems_task_self();
ctx->jobs = jobs;
ctx->job_count = job_count;
diff --git a/cpukit/libtrace/record/record-server.c b/cpukit/libtrace/record/record-server.c
index da7cf358d3..840924a24a 100644
--- a/cpukit/libtrace/record/record-server.c
+++ b/cpukit/libtrace/record/record-server.c
@@ -147,7 +147,7 @@ void _Record_Stream_header_initialize( Record_Stream_header *header )
header->Processor_maximum.event =
RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PROCESSOR_MAXIMUM );
- header->Processor_maximum.data = rtems_get_processor_count() - 1;
+ header->Processor_maximum.data = rtems_scheduler_get_processor_maximum() - 1;
header->Count.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PER_CPU_COUNT );
header->Count.data = _Record_Item_count;
diff --git a/cpukit/posix/src/sysconf.c b/cpukit/posix/src/sysconf.c
index c5f66f6f46..7227a6d11c 100644
--- a/cpukit/posix/src/sysconf.c
+++ b/cpukit/posix/src/sysconf.c
@@ -50,7 +50,7 @@ long sysconf(
case _SC_NPROCESSORS_CONF:
return (long) rtems_configuration_get_maximum_processors();
case _SC_NPROCESSORS_ONLN:
- return (long) rtems_get_processor_count();
+ return (long) rtems_scheduler_get_processor_maximum();
case _SC_POSIX_26_VERSION:
return (long) _POSIX_26_VERSION;
#if defined(__sparc__)
diff --git a/cpukit/rtems/src/getprocessorcount.c b/cpukit/rtems/src/getprocessorcount.c
index 438eec6635..40ab5ef9d9 100644
--- a/cpukit/rtems/src/getprocessorcount.c
+++ b/cpukit/rtems/src/getprocessorcount.c
@@ -16,10 +16,10 @@
#include "config.h"
#endif
-#include <rtems/rtems/smp.h>
+#include <rtems/rtems/tasks.h>
#include <rtems/score/smp.h>
-uint32_t rtems_get_processor_count(void)
+uint32_t rtems_scheduler_get_processor_maximum(void)
{
return _SMP_Get_processor_count();
}
diff --git a/cpukit/sapi/src/profilingiterate.c b/cpukit/sapi/src/profilingiterate.c
index 9ec46fc97a..79754651f0 100644
--- a/cpukit/sapi/src/profilingiterate.c
+++ b/cpukit/sapi/src/profilingiterate.c
@@ -31,7 +31,7 @@ static void per_cpu_stats_iterate(
)
{
#ifdef RTEMS_PROFILING
- uint32_t n = rtems_get_processor_count();
+ uint32_t n = rtems_scheduler_get_processor_maximum();
uint32_t i;
memset(data, 0, sizeof(*data));