2019-08-17 00:42:25 +02:00
|
|
|
/****************************************************************************
|
2021-03-08 22:39:04 +01:00
|
|
|
* mm/iob/iob_statistics.c
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
2024-09-12 16:44:55 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-05-26 09:55:08 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
2021-05-26 09:55:08 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
2021-05-26 09:55:08 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2019-08-19 19:50:52 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
|
|
|
|
2022-08-08 04:21:03 +02:00
|
|
|
#include "iob.h"
|
|
|
|
|
2019-08-17 00:42:25 +02:00
|
|
|
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_PROCFS) && \
|
|
|
|
!defined(CONFIG_FS_PROCFS_EXCLUDE_IOBINFO)
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: iob_getuserstats
|
|
|
|
*
|
|
|
|
* Description:
|
2021-02-08 16:19:12 +01:00
|
|
|
* Return a reference to the IOB usage statistics for the IOB
|
|
|
|
* consumer/producer
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
2022-08-08 04:21:03 +02:00
|
|
|
* stats - point to IOB usage statistics
|
2019-08-17 00:42:25 +02:00
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-08-08 04:21:03 +02:00
|
|
|
void iob_getstats(FAR struct iob_stats_s *stats)
|
2019-08-17 00:42:25 +02:00
|
|
|
{
|
2022-08-08 04:21:03 +02:00
|
|
|
stats->ntotal = CONFIG_IOB_NBUFFERS;
|
|
|
|
|
|
|
|
nxsem_get_value(&g_iob_sem, &stats->nfree);
|
|
|
|
if (stats->nfree < 0)
|
|
|
|
{
|
|
|
|
stats->nwait = -stats->nfree;
|
|
|
|
stats->nfree = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stats->nwait = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_IOB_THROTTLE > 0
|
|
|
|
nxsem_get_value(&g_throttle_sem, &stats->nthrottle);
|
|
|
|
if (stats->nthrottle < 0)
|
|
|
|
{
|
|
|
|
stats->nthrottle = -stats->nthrottle;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
stats->nthrottle = 0;
|
|
|
|
}
|
2019-08-17 00:42:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !CONFIG_DISABLE_MOUNTPOINT && CONFIG_FS_PROCFS &&
|
|
|
|
* !CONFIG_FS_PROCFS_EXCLUDE_IOBINFO */
|