Question 1 Fork system call
1.used to get the pid of the parent process
2.used to call functions in separate threads
3.ed to create a child process
4.creates an exact copy of the parent process
Question 2 Fork system call
- in the parent process, calling the fork returns the pid of the child
- in the child process, calling fork returns 0
- in the child process, calling fork returns the pid of the parent process
-
in the parent process, the call to fork returns 0
Question 3 What happens to the memory in the child process when working with Python?
-
Copied from parent process
- Shared with parent process
Question 4 File Descriptors in the child process
- will be rediscovered by the Python interpreter automatically
- will be unavailable, they need to be rediscovered
- will be copied and rediscovered
-
will be copied
Question 5 Highlight true expressions:
-
it is preferable to use the context manager to work with locks in Python
- locks must be taken in the same order, released in an arbitrary
- locks must be taken in the same order, released strictly in the same manner
-
locks must be taken in the same order, released in reverse
Question 6 Queues slow down the workflow of Python threads, better use blocking objects
-
Not
-
Yes
Question 7 Highlight true expressions:
-
GIL slows down the execution of the main control flow in Python3, even if there are no other threads.
- GIL does not affect the execution of individual processes in Python3.
- GIL prohibits simultaneous execution of bytecode instructions in different streams.
- GIL is needed to protect the interpreter's memory from damage
. Question 8 If a Python program performs many I / O operations (IO-bound), then to speed up its work you need
- break it into separate functions, execute them in streams
-
create separate processes
Question 9 If a Python program performs calculations that require only a CPU (CPU-bound), then to speed up its work,
-
break it into separate functions, execute them in streams
- create separate processes
Question 10 Python generator is
- yield instruction
- function in which there is a yield statement
- special call yield from
- object of type concurrent.futures.Future
Question 11 Mark all true statements:
- the generator stores the value to generate the next sequence element in local variables
- exception StopIteration is used to stop the iterator
- the iterator stores the value to generate the next sequence element in self
-
the iterator interrupts its execution at each iteration, preserving the state of local variables
Question 12 Mark all true statements:
-
exceptions cannot be handled in coroutines; this should be done in the main thread
- from one coroutine, you can call another with yield from
- coroutines are executed in separate threads in parallel
- The coroutine can interrupt its work, preserving its state and the values of all local variables
Question 13 Mark all true statements regarding the asyncio event loop:
- allows you to perform callable functions and python objects
- performs all the corutines in sequence, switching the context between them
- responsible for memory allocation in the main process
- allows you to perform korutiny registered in it
- performs several corutin in parallel in different threads
-
switch context between python threads
Question 14 Mark all true statements:
-
an object of type asyncio.Task stores the associated coruntine and contains the status of its execution
- the blocking code in Python will not affect the execution of other korutin in the asyncio event loop
- You can create chains from objects of the asyncio.Future type and wait for them to run in the asyncio event loop
- an object of type asyncio.Task is executed in a separate control flow, without affecting the execution of other objects of type asyncio.Task
Aucun commentaire:
Enregistrer un commentaire