aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/common/erl_check_io.h
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-05-30 16:35:18 +0200
committerLukas Larsson <[email protected]>2017-10-02 10:35:52 +0200
commit988f5f5e8061ce2e135a314ca782788eda478a06 (patch)
tree1609c42abb9ed03a176865ee32ad3de803c392d3 /erts/emulator/sys/common/erl_check_io.h
parent1f9003a3dd9bbf9e3dcd84b8fdecef04a3b5e9c7 (diff)
downloadotp-988f5f5e8061ce2e135a314ca782788eda478a06.tar.gz
otp-988f5f5e8061ce2e135a314ca782788eda478a06.tar.bz2
otp-988f5f5e8061ce2e135a314ca782788eda478a06.zip
erts: Move all I/O polling to a seperate thread
Diffstat (limited to 'erts/emulator/sys/common/erl_check_io.h')
-rw-r--r--erts/emulator/sys/common/erl_check_io.h92
1 files changed, 77 insertions, 15 deletions
diff --git a/erts/emulator/sys/common/erl_check_io.h b/erts/emulator/sys/common/erl_check_io.h
index ab53d91756..443ef1264c 100644
--- a/erts/emulator/sys/common/erl_check_io.h
+++ b/erts/emulator/sys/common/erl_check_io.h
@@ -18,10 +18,11 @@
* %CopyrightEnd%
*/
-/*
- * Description: Check I/O
+/**
+ * @description Check I/O, a cross platform IO polling framework for ERTS
*
- * Author: Rickard Green
+ * @author Rickard Green
+ * @author Lukas Larsson
*/
#ifndef ERL_CHECK_IO_H__
@@ -30,35 +31,96 @@
#include "sys.h"
#include "erl_sys_driver.h"
-struct pollset_info;
+/** @brief a structure that is used by each polling thread */
+struct erts_poll_thread;
+/**
+ * Get the memory size of the check io framework
+ */
Uint erts_check_io_size(void);
-Eterm erts_check_io_info(void *);
-void erts_io_notify_port_task_executed(ErtsPortTaskHandle *pthp);
-void erts_check_io_async_sig_interrupt(struct pollset_info *psi);
+/**
+ * Returns an Eterm with information about all the pollsets active at the
+ * moment.
+ *
+ * @param proc the Process* to allocate the result on. It is passed as
+ * void * because of header include problems.
+ */
+Eterm erts_check_io_info(void *proc);
+/**
+ * Should be called when a port IO task has been executed in order to re-enable
+ * or clear the information about the fd.
+ *
+ * @param type The type of event that has been completed.
+ * @param handle The port task handle of the event.
+ * @param reset A function pointer to be called when the port task handle
+ * should be reset.
+ */
+void erts_io_notify_port_task_executed(ErtsPortTaskType type,
+ ErtsPortTaskHandle *handle,
+ void (*reset)(ErtsPortTaskHandle *));
+/**
+ * Returns the maximum number of fds that the check io framework can handle.
+ */
int erts_check_io_max_files(void);
-void erts_check_io(int);
-void erts_init_check_io(void);
+/**
+ * Called by any thread that should check for new IO events. This function will
+ * not return unless erts_check_io_interrupt(pt, 1) is called by another thread.
+ *
+ * @param pt the poll thread structure to use.
+ */
+void erts_check_io(struct erts_poll_thread *pt);
+/**
+ * Initialize the check io framework. This function will parse the arguments
+ * and delete any entries that it is interested in.
+ *
+ * @param argc the number of arguments
+ * @param argv an array with the arguments
+ */
+void erts_init_check_io(int *argc, char **argv);
+/**
+ * Interrupt the poll thread so that it can execute other code.
+ *
+ * Should be called with set = 0 by the waiting thread before calling
+ * erts_check_io.
+ *
+ * @param pt the poll thread to wake
+ * @param set whether to set or clear the interrupt flag
+ */
+void erts_check_io_interrupt(struct erts_poll_thread *pt, int set);
+/**
+ * Create a new poll thread structure that is associated with the number no.
+ * It is the callers responsibility that no is unique.
+ */
+struct erts_poll_thread* erts_create_pollset_thread(int no);
#ifdef ERTS_ENABLE_LOCK_COUNT
+/**
+ * Toggle lock counting on all check io locks
+ */
void erts_lcnt_update_cio_locks(int enable);
#endif
-void erts_check_io_interrupt(struct pollset_info*, int);
-void erts_check_io_interrupt_timed(struct pollset_info*, int, ErtsMonotonicTime);
-struct pollset_info* erts_get_pollset(int sched_num);
-
typedef struct {
ErtsPortTaskHandle task;
- erts_atomic_t executed_time;
- struct pollset_info *pollset;
+ ErtsSysFdType fd;
} ErtsIoTask;
+
#endif /* ERL_CHECK_IO_H__ */
#if !defined(ERL_CHECK_IO_C__) && !defined(ERTS_ALLOC_C__)
#define ERL_CHECK_IO_INTERNAL__
#endif
+#define ERTS_CHECK_IO_DRV_EV_STATE_LOCK_CNT 128
+
+/* Controls how many pollsets to allocate. Fd's are hashed into
+ each pollset based on the FD. When doing non-concurrent updates
+ there will be one pollset per thread.
+*/
+extern int erts_no_pollsets;
+extern int erts_no_poll_threads;
+
+
#ifndef ERL_CHECK_IO_INTERNAL__
#define ERL_CHECK_IO_INTERNAL__
#include "erl_poll.h"