wait()yield()pause()resume()luaproc is used for:luaproc library help in Lua’s concurrency model?start()continue()resume()return()yield() in Lua?luaprocsocket.select() function in Lua help manage?luasocket be used for in asynchronous task handling?luasocket for non-blocking I/O| Qno | Answer |
|---|---|
| 1 | b) Single-threading |
| 2 | b) Only one thread is executed at a time. |
| 3 | b) By switching contexts between tasks |
| 4 | b) Lua allows for parallel execution of tasks. |
| 5 | a) The functions are processed sequentially, one after the other. |
| 6 | b) To allow functions to yield and resume execution |
| 7 | b) Coroutines share the same thread and can pause their execution. |
| 8 | b) yield() |
| 9 | a) Implementing multithreading in Lua |
| 10 | a) It uses multiple Lua interpreters for parallel execution. |
| 11 | b) They can help simulate multitasking without multiple threads. |
| 12 | c) resume() |
| 13 | b) Coroutines allow for cooperative multitasking. |
| 14 | b) It is paused and can be resumed. |
| 15 | c) Coroutines cannot achieve true parallelism in Lua’s single-threaded model. |
| 16 | b) Coroutines |
| 17 | b) By using coroutines that yield and resume execution |
| 18 | b) Lua events and callbacks |
| 19 | a) By using timers that run after a specific delay |
| 20 | c) Avoiding task blocking due to single-threading |
| 21 | c) Using non-blocking I/O with callbacks |
| 22 | b) It selects which task to execute asynchronously based on input/output readiness. |
| 23 | b) It prevents blocking of the main execution thread during I/O operations. |
| 24 | b) Using event-driven programming with non-blocking calls |
| 25 | b) They prevent other tasks from executing until they are completed. |
| 26 | b) Handling non-blocking network connections |
| 27 | c) Simplifying multi-core processing |
| 28 | b) Event loop with callback functions |
| 29 | b) Lua throws an error. |
| 30 | b) By using coroutines with luasocket for non-blocking I/O |