Questions #1


What is the difference between threading and multiprocessing?



Download 85,32 Kb.
bet12/24
Sana06.07.2022
Hajmi85,32 Kb.
#752107
1   ...   8   9   10   11   12   13   14   15   ...   24
Bog'liq
interview en

What is the difference between threading and multiprocessing?
The main difference is in memory sharing. Processes are independent of each other, have separate address spaces, identifiers, resources. Threads are executed in a shared address space, have shared access to memory, variables, loaded modules.
Which tasks are well parallelized, which ones are bad?
Those tasks that generate long IO. When a thread hits a socket or disk wait, the interpreter abandons that thread and starts the next one. This means there will be no downtime due to waiting. On the contrary, if you go to the network in one thread (in a cycle), then each time you have to wait for a response.
However, if the thread then processes the received data, then only it will be executed. This will not only not give an increase in speed, but also slow down the program due to switching to other threads.
The short answer is that networking tasks fit well with threads. For example, download a hundred urls. Process the received data outside of threads.
You need to calculate 100 equations. Do it in threads or not?
No, because there is no I/O in this task. The interpreter will only spend extra time switching threads. It is better to move complex mathematical problems into separate processes, or use the Celery framework for distributed tasks, or connect them as C-libraries.
Are Python threads native threads or not?
Yes, these are native Posix-compliant threads that run at the operating system level.
What are greenlets? General concept. Implementation examples.
Greenlet == Green thread == Green threads == lightweight threads inside a virtual machine. They can be called coroutines, coprocesses, actors, etc. platform dependent. The operating system does not see them. From the point of view of the OS, one process of the virtual machine is running, and what is inside it is unknown. Such threads are managed by the virtual machine itself: it generates, executes, and coordinates access to resources.
Examples: coroutines in Go and Lua, lightweight processes in Erlang, the greenlet module for Python.

Django



Download 85,32 Kb.

Do'stlaringiz bilan baham:
1   ...   8   9   10   11   12   13   14   15   ...   24




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish