Commit Graph

29 Commits

Author SHA1 Message Date
Philippe Gerum 3fef97c67b lib: convert to HM diagnostic messages
Since ABI 23, the core is able to channel T_WOSS, T_WOLI and T_WOSX
error notifications through the offender's observable component if
present.

Convert all SIGDEBUG_xxx cause codes to the new EVL_HMDIAG_xxx naming,
so that we have a single nomenclature for these errors regardless of
whether threads are notified via SIGDEBUG or their observable
component.

The API rev. is bumped to #17 as a result of these changes.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-30 12:11:14 +02:00
Philippe Gerum f27fc99387 lib: introduce the interface to observables
Since ABI 23, the core provides the new observable element, which
enables the observer design pattern. Any EVL thread is in and of
itself an observable which can be monitored for events too.

As a by-product, the poll interface can now be given a user-defined
opaque data when subscribing file descriptors to poll elements, which
the core passes back on return to evl_poll().

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-30 12:11:14 +02:00
Philippe Gerum dbb8d32f08 lib/thread: add services to set/clear thread mode bits
Open-coding oob_ioctl() calls to set/clear mode bits in apps is
unhandy and fairly ugly. Let's provide sanctioned services for these
requests, namely evl_set_thread_mode() and evl_clear_thread_mode()
respectively.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-23 14:30:58 +02:00
Philippe Gerum 207ad9feb3 lib/thread: add unblock and demotion services
Starting with ABI 22, we can ask for the core to unblock a thread from
a wait state, which may include forcing it out of any real-time
scheduling class by demoting it to SCHED_WEAK in the same move.

Export evl_unblock_thread() and evl_demote_thread() as the
corresponding wrappers.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-23 12:52:54 +02:00
Philippe Gerum 55bb9159aa lib/sched: add evl_yield() for manual round-robin
An equivalent of sched_yield().

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-23 12:52:54 +02:00
Philippe Gerum c8b3bb1cca lib/thread: rename evl_attach_self_flags() to evl_attach_thread()
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-21 19:08:05 +02:00
Philippe Gerum 9b42b85ed8 lib: introduce element visibility attribute
Since core ABI 21, users can decide whether a new element should be
made public or private depending on the value of clone flags added to
the new long form of all element creation calls, i.e. evl_create_*().
All evl_new_*() calls become a shorthand for their respective long
form with reasonable default arguments, including private visibility.

As a shorthand, libevl also interprets a slash character leading the
name argument passed to these services as an implicit request for
creating a public element. In other words, this is the same as passing
EVL_CLONE_PUBLIC in the clone flags.

A public element appears as a cdev in the /dev/evl hierarchy, which
means that it is visible to other processes, which may share it. On
the contrary, a private element is only known from the process
creating it, although it does appear in the /sysfs hierarchy
regardless.

e.g.:

efd = evl_attach_self("/visible-thread");

total 0
crw-rw----    1 root     root      248,   1 Apr 17 11:59 clone
crw-rw----    1 root     root      246,   0 Apr 17 11:59 visible-thread

or,

efd = evl_attach_self("private-thread");

total 0
crw-rw----    1 root     root      248,   1 Apr 17 11:59 clone

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-18 20:43:02 +02:00
Philippe Gerum a30208946c lib/sched: rename evl_sched_control() to evl_control_sched()
Given that evl_sched_control() was hardly usable prior to the latest
fixes to the scheduler control code in the core and no feedback ever
happened about such issues, we may assume that such call has no user
yet. Take this opportunity to fix a naming inconsistency in the API.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-04-17 07:51:44 +02:00
Philippe Gerum f518a3cab9 all: convert to ABI enabling compat syscall support
These changes fix up the argument passed to the core system calls in
order to abide by the new ABI allowing 32bit applications to issue
requests to 64bit kernels.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-03-28 11:23:55 +01:00
Philippe Gerum a9f1e2f678 lib: fix unfortunate misnomer 2020-03-19 12:30:55 +01:00
Philippe Gerum 4204f25b5c lib: y2038: convert to timespec64 kernel interface
This set of changes makes libevl y2038-safe by switching to the ABI
revision 19 of the EVL core, which generalizes the use of a 64bit
timespec type. These changes also go a long way preparing for the
upcoming mixed 32/64 ABI support (aka compat mode).

The changes only affect the internal interface between libevl and the
kernel, not the API.  Nevertheless, the API was bumped to revision 10
with the removal of the evl_adjust_clock() service, which neither had
proper specification nor defined use case currently, but would stand
in the way of the sanitization work for y2038. At any rate, any future
service implementing some sort of EVL clock adjustment should
definitely not depend on the legacy struct timex which is
y2038-unsafe.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-03-19 12:30:55 +01:00
Philippe Gerum 1565744da2 lib/init: state ABI requirement explicitly
Instead of matching whatever ABI we might be compiled against like
previously, define the kernel ABI we need as a prerequisite
(EVL_KABI_PREREQ), checking for sanity at build time and runtime.

This prerequisite is matched against the range of ABI revisions the
kernel supports (from EVL_ABI_BASE to EVL_ABI_CURRENT). In the
simplest case, the kernel implements a single ABI with no backward
compatibility mechanism (EVL_ABI_BASE == EVL_ABI_CURRENT).

This addresses two issues:

- the fact that libevl might build against a given set of uapi/ files
  does not actually mean that the corresponding kernel ABI found there
  is fully compatible with what libevl expects. Specifying a
  compatible ABI prereq explicitly addresses this problem.

- we can obtain services from EVL cores supporting multiple ABI
  revisions (i.e. providing backward compat feat).

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
2020-03-19 12:30:45 +01:00
Philippe Gerum 01f1cc273d include/evl: drop leftover declaration 2020-02-26 18:56:20 +01:00
Philippe Gerum db712cc191 lib: rename evl_udelay() to evl_usleep()
evl_udelay() was an annoying misnomer for people with kernel
development background, as this relates to a busy wait loop, not to a
sleeping call, which evl_udelay() actually was.

Rename this call to evl_usleep(), converging to the glibc signature
for usleep(3) in the same move.
2020-01-21 14:52:21 +01:00
Philippe Gerum 08592109f8 include: add 'tube' data path
A lighweight, lockless multi-reader/multi-writer FIFO with a
base-offset variant which can work over a memory segment shared
between processes. Scalar data or simple (small!) aggregates are
conveyed though a tube inside canisters which exactly fit their type.
By design, a tube is meant to be a basic, spartan mechanism: it
imposes no usage policy whatsoever on users.

As a result, a tube is strictly non-blocking, it solely detects and
notifies the caller on return about empty input (no message in) and
output contention (no buffer space for output). If required, the
caller can implement blocking states, typically with a pair of EVL
semaphores, e.g. setting up a tube conveying integers which supports
blocking mode:

    DECLARE_EVL_TUBE_CANISTER(canister_type, int); /* defines struct canister_type */
    DECLARE_EVL_TUBE(tube_type, cannister_type) tube;
    struct cannister_type items[1024];

    evl_init_tube(&tube, items, 1024);
    evl_new_sem(&in, ...);
    evl_new_sem_any(&out, CLOCK_MONOTONIC, tube.max_items, ...);

    evl_get_sem(&in, ...);           @      evl_get_sem(&out);
    evl_tube_receive(&tube, ...);    @      evl_tube_send(&tube, ...);
    evl_put_sem(&out);               @      evl_put_sem(&in, ...);
2019-11-19 10:30:13 +01:00
Philippe Gerum d9f26b70b0 lib, eshi: move version string to evl_version 2019-11-13 10:00:39 +01:00
Philippe Gerum 154e577193 lib, eshi: add evl_get_version()
Returns version information about the running EVL interface including
the API and kernel ABI levels. A negative ABI level denotes the EVL
shim layer (eshi).
2019-11-13 09:25:53 +01:00
Philippe Gerum 2738fcfc3f evl: bump API revision
In the wake of adding recursive mutexes and compact creation calls for
synchronization objects.
2019-08-19 10:24:28 +02:00
Philippe Gerum 5353db0df9 lib/sem: fix how evl_peek_sem() returns the count value
-EINVAL and a negative (depleted) semaphore count value might be
conflicting. Retrieve the count value by address instead.
2019-07-21 18:56:10 +02:00
Philippe Gerum 51b8c157a4 lib/sched: export evl_get_cpustate()
This routine is mainly intended as a tool for applications to
implement LARTs, notably returning the isolation state of a CPU. This
helps in detecting when a user is about to run out-of-band work on a
non-isolated CPU.

Although a dual kernel system performs significantly better than a
native preemption system in this configuration, getting the smallest
jitter and latency figures will require running the out-of-band load
on an isolated core, so that the in-band work does not increase the
rate of cache misses for the out-of-band duties.
2019-07-02 15:38:20 +02:00
Philippe Gerum b1a5755354 lib/proxy: add message formatting routines to proxy stream 2019-06-30 13:07:25 +02:00
Philippe Gerum 6bfb86253d lib/sched: add sched-specific implementation file 2019-06-30 13:07:14 +02:00
Philippe Gerum c78307fd04 lib/clock: drop meaningless parameter from evl_sleep()
evl_sleep() only accepts absolute timespecs, so there is no point in
providing a pointer for collecting the remaining time upon interrupt.
2019-06-29 19:34:52 +02:00
Philippe Gerum 85018fc262 lib/proxy: enable fixed granularity for writes
This change allows the application to specify a fixed granularity for
writes to the target file, such as connecting the proxy with an
eventfd for instance, guaranteeing fixed-size 64bit writes to the
latter.

evl_poll() is also enabled for the proxy, with POLLOUT|POLLWRNORM
raised when the output has drained, i.e. all data have been sent to
the target file.
2019-06-29 16:41:07 +02:00
Philippe Gerum c96ec86e65 include/evl: read evl/flags.h from central header 2019-06-27 17:08:36 +02:00
Philippe Gerum f0d37f4730 treewide: API update
Improve consistency in naming and disambiguate some calls.
2019-06-13 10:31:04 +02:00
Philippe Gerum 13f521985a utils/latmus: dump test information header with -g 2019-05-29 14:58:12 +02:00
Philippe Gerum da612bee52 lib/init: rename sigshadow to sigevl 2019-04-22 18:16:49 +02:00
Philippe Gerum eda7791f9b evl: rename evenless/ paths to evl/ 2019-03-10 16:25:02 +01:00