1.. SPDX-License-Identifier: BSD-3-Clause 2 Copyright(c) 2010-2014 Intel Corporation. 3 4Hello World Sample Application 5============================== 6 7The Hello World sample application is an example of the simplest DPDK application that can be written. 8The application simply prints an "helloworld" message on every enabled lcore. 9 10Compiling the Application 11------------------------- 12 13To compile the sample application see :doc:`compiling`. 14 15The application is located in the ``helloworld`` sub-directory. 16 17Running the Application 18----------------------- 19 20To run the example in a linux environment: 21 22.. code-block:: console 23 24 $ ./<build_dir>/examples/dpdk-helloworld -l 0-3 -n 4 25 26Refer to *DPDK Getting Started Guide* for general information on running applications 27and the Environment Abstraction Layer (EAL) options. 28 29Explanation 30----------- 31 32The following sections provide some explanation of code. 33 34EAL Initialization 35~~~~~~~~~~~~~~~~~~ 36 37The first task is to initialize the Environment Abstraction Layer (EAL). 38This is done in the main() function using the following code: 39 40.. literalinclude:: ../../../examples/helloworld/main.c 41 :language: c 42 :start-after: Initialization of Environment Abstraction Layer (EAL). 8< 43 :end-before: >8 End of initialization of Environment Abstraction Layer 44 45This call finishes the initialization process that was started before main() is called (in case of a Linux environment). 46The argc and argv arguments are provided to the rte_eal_init() function. 47The value returned is the number of parsed arguments. 48 49Starting Application Unit Lcores 50~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 51 52Once the EAL is initialized, the application is ready to launch a function on an lcore. 53In this example, lcore_hello() is called on every available lcore. 54The following is the definition of the function: 55 56.. literalinclude:: ../../../examples/helloworld/main.c 57 :language: c 58 :start-after: Launch a function on lcore. 8< 59 :end-before: >8 End of launching function on lcore. 60 61The code that launches the function on each lcore is as follows: 62 63.. literalinclude:: ../../../examples/helloworld/main.c 64 :language: c 65 :start-after: Launches the function on each lcore. 8< 66 :end-before: >8 End of launching the function on each lcore. 67 :dedent: 1 68 69The following code is equivalent and simpler: 70 71.. literalinclude:: ../../../examples/helloworld/main.c 72 :language: c 73 :start-after: Simpler equivalent. 8< 74 :end-before: >8 End of simpler equivalent. 75 :dedent: 2 76 77Refer to the *DPDK API Reference* for detailed information on the rte_eal_mp_remote_launch() function. 78