multithreading - Threads and Processors -
i'm learning multithreading, threads, threadpools, , such. have read number of threads cannot more number of logical processors computer has (or @ least there no advantage gained since cpu cannot handle more).
so expected behavior if write code created hundreds of threads on computer say, 12 logical processors? queue up? wait each other? or give error? if have process benefit 100 continuously running threads, have 12 cores, best way handle this? open task manager see hundreds of processes , thousands of threads running. how work?
also, if i'm running program in windows, bunch of other applications running (ie. chrome, ms excel, skype, ect...), , perhaps bunch of background services (ie. windows defender, wifi services, ect...) these other applications take logical processors, decreasing number of logical processors available threaded program?
as thilo hinted at, modern personal computers perpetually creating, executing, , destroying dozens if not hundreds of threads/processes @ given slice of time. number of threads being processed on cpu can not exceed number of logical cores, however, not mean there can not many more threads waiting executed.
what expected behavior if write code created hundreds of threads on computer say, 12 logical processors?
if make assumption environment (framework, platform, language, os, hardware) being used create these threads can support many concurrent threads, result each thread scheduled operating system based on number of available cores , priority of threads relative of other running threads/processes. behavior can vary drastically depending on specific operating system, tool set, program type (kernel mode / user mode on windows), , hardware running code.
as side note, traditional threads can expensive use because forces processor context-switch (flush caches, load new context, execute). there other techniques can work around issue extent (such task parallelism library .net, or parallel patterns library c++) when solving specific problems.
if have process benefit 100 continuously running threads, have 12 cores, best way handle this?
this depends on task @ hand , environment working in. asynchronous programming very big topic in computer science, , such, there large number of techniques , libraries available - each benefits , draw backs.
Comments
Post a Comment