分布式系统 进程&线程与分布式
本文最后更新于 172 天前,如有失效请评论区留言。

Thread

  • Granularity(粒度) of processes as provided by the operating systems on which distributed systems are built is not sufficient. (操作系统给的进程的资源过大,粒度不都细)

  • Multiple threads per process makes it much easier to build distributed applications and to attain better performance. (真正并发的是线程)

Process & Thread

  • Processes ensure concurrency transparency costly;

  • Threads minimum concurrency transparency and let the developers deal with the mutex (mutual exclusion) variable;

  • One CPU execute only one process in time;

  • Process contains and manages many threads

  • Java threads and JVM;

线程的存在是为了防止进程在执行时被阻塞,即进程内并行。最终实现操作系统层面进程并行的效果。

小A给小B打电话,B正在吃饭。(电话相当于操作系统的通信)如果是单线程,B接电话就不能吃饭,只能一直等着。如果是多线程B可以一边接电话,一边吃饭。

只有单线程,意味着系统call的时候,相当于发了一个中断。

Threads in Distributed Systems

  • Thread can provide a convenient means of allowing blocking system calls without blocking the entire process in which the thread is running.

  • Multi-threaded Clients

  • Multi-threaded Servers

Multi-threaded Clients

• To establish a high degree of distribution
transparency, distributed systems that operate in
wide-area networks may need to hide
communication latencies.
– Initiate communication and immediately
proceed with something else

Web Brower

  • Browsers start displaying data while it is still coming in

  • Threads for process text, images, scrolling, scripts,
    etc.

  • Web servers have been replicated across multiple
    machines, where each server provides exactly the
    same set of Web documents.

  • Single thread client : the request is forwarded to one
    of the servers, load-balancing such as round-robin;

  • Multithreaded client: connections may be set up to
    different replicas, allowing data to be transferred in
    parallel

Multithreaded Servers

Blocking system calls make programming easier and parallelism improves performance.
– Multi-threaded: blocking system calls and still achieve parallelism.
– Single-threaded: simplicity of blocking system calls, but gives up performance.
– The finite-state machine: achieves high performance through parallelism, but uses non-blocking calls, thus is hard to program.

Virtulazation in Distributed System(虚拟化)

本质: 用一个接口,实现另外一个接口

Virtualization in Different Level

  • An interface between the hardware and software, consisting of machineinstructions that can be invoked by any program.

  • An interface between the hardware and software, consisting of machine instructions that can be invoked only by privileged programs, such as an operating system.

  • An interface consisting of system calls as offered by an operating system.

  • An interface consisting of library calls, generally forming what is known as an application programming interface (API).

虚拟机把一个机器可以拆分成很多小机器。分布式则相反,可以把很多台机器合为一个,对上提供服务感觉是一台机器。

版权声明:本文为火灵飞原创,依据CC BY-SA 4.0许可证进行授权,转载请附上原文链接及本声明。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇