iPXE
Functions
process.c File Reference

Processes. More...

#include <ipxe/list.h>
#include <ipxe/init.h>
#include <ipxe/process.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static LIST_HEAD (run_queue)
 Process run queue.
void * process_object (struct process *process)
 Get pointer to object containing process.
void process_add (struct process *process)
 Add process to process list.
void process_del (struct process *process)
 Remove process from process list.
void step (void)
 Single-step a single process.
static void init_processes (void)
 Initialise processes.
struct init_fn process_init_fn __init_fn (INIT_NORMAL)
 Process initialiser.

Detailed Description

Processes.

We implement a trivial form of cooperative multitasking, in which all processes share a single stack and address space.

Definition in file process.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
static LIST_HEAD ( run_queue  ) [static]

Process run queue.

void* process_object ( struct process process)

Get pointer to object containing process.

Parameters:
processProcess
Return values:
objectContaining object

Definition at line 47 of file process.c.

Referenced by step().

                                                  {
        return ( ( ( void * ) process ) - process->desc->offset );
}
void process_add ( struct process process)

Add process to process list.

Parameters:
processProcess

It is safe to call process_add() multiple times; further calls will have no effect.

Definition at line 59 of file process.c.

References DBGC, process::list, list_add_tail, PROC_COL, PROC_DBG, PROC_FMT, process_running(), ref_get, and process::refcnt.

Referenced by efi_pxe_udp_schedule_close(), fc_els_request(), fcpcmd_start_send(), http_reopen(), hub_complete(), hub_open(), ib_cmrc_close(), init_processes(), iscsi_tx_resume(), net80211_autoassociate(), peerblk_retrieval_close(), peermux_block_close(), peermux_info_close(), process_init(), sanpath_open(), scsidev_ready(), tcp_close(), tcp_rx(), tls_tx_resume(), validator_xfer_close(), and xcm_reopen().

                                             {
        if ( ! process_running ( process ) ) {
                DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
                       " starting\n", PROC_DBG ( process ) );
                ref_get ( process->refcnt );
                list_add_tail ( &process->list, &run_queue );
        } else {
                DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
                       " already started\n", PROC_DBG ( process ) );
        }
}
void process_del ( struct process process)

Remove process from process list.

Parameters:
processProcess

It is safe to call process_del() multiple times; further calls will have no effect.

Definition at line 79 of file process.c.

References DBGC, INIT_LIST_HEAD, process::list, list_del, PROC_COL, PROC_DBG, PROC_FMT, process_running(), ref_put, and process::refcnt.

Referenced by efi_local_close(), efi_pxe_udp_close(), efi_pxe_udp_open(), fc_els_close(), fc_ns_query_close(), fcpcmd_stop_send(), http_close(), hub_close(), hub_refill(), hw_finished(), ib_cmrc_shutdown(), iscsi_close(), iscsi_tx_pause(), net80211_netdev_close(), net80211_step_associate(), peerblk_reset(), peermux_close(), peermux_step(), sanpath_close(), scsidev_close(), step(), tcp_close(), tls_close(), validator_finished(), xcm_close(), xcm_destroy(), and xcm_reopen().

                                             {
        if ( process_running ( process ) ) {
                DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
                       " stopping\n", PROC_DBG ( process ) );
                list_del ( &process->list );
                INIT_LIST_HEAD ( &process->list );
                ref_put ( process->refcnt );
        } else {
                DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
                       " already stopped\n", PROC_DBG ( process ) );
        }
}
void step ( void  )

Single-step a single process.

This executes a single step of the first process in the run queue, and moves the process to the end of the run queue.

Definition at line 98 of file process.c.

References DBGC2, process::desc, process::list, list_add_tail, list_del, list_first_entry, PROC_COL, PROC_DBG, PROC_FMT, process_del(), process_object(), ref_get, ref_put, process::refcnt, process_descriptor::reschedule, and process_descriptor::step.

Referenced by ath5k_hw_rf_check_gainf_readback(), ath5k_hw_rf_gainf_corr(), comboot_resolv(), efi_download_poll(), efi_ifr_numeric_op(), efi_pxe_dhcp(), efi_pxe_mtftp(), efi_pxe_udp_read(), getchar(), getchar_timeout(), int22(), iwlist(), md4_digest(), md5_digest(), monojob_wait(), open(), pxenv_tftp_get_fsize(), pxenv_tftp_open(), pxenv_tftp_read(), pxenv_tftp_read_file(), pxenv_udp_read(), read_user(), sandev_command(), sandev_describe(), sandev_reopen(), select(), sha1_digest(), sleep_interruptible(), spi_bit_transfer(), and tcp_shutdown().

                   {
        struct process *process;
        struct process_descriptor *desc;
        void *object;

        if ( ( process = list_first_entry ( &run_queue, struct process,
                                            list ) ) ) {
                ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
                desc = process->desc;
                object = process_object ( process );
                if ( desc->reschedule ) {
                        list_del ( &process->list );
                        list_add_tail ( &process->list, &run_queue );
                } else {
                        process_del ( process );
                }
                DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
                        " executing\n", PROC_DBG ( process ) );
                desc->step ( object );
                DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
                        " finished executing\n", PROC_DBG ( process ) );
                ref_put ( process->refcnt ); /* Allow destruction */
        }
}
static void init_processes ( void  ) [static]

Initialise processes.

Definition at line 127 of file process.c.

References for_each_table_entry, PERMANENT_PROCESSES, and process_add().

                                    {
        struct process *process;

        for_each_table_entry ( process, PERMANENT_PROCESSES )
                process_add ( process );
}
struct init_fn process_init_fn __init_fn ( INIT_NORMAL  ) [read]

Process initialiser.