模块三考核题目

模块三

***来源:www.luffycity.com***

1.TCP 三次握手的过程

      客户端                                                服务端

  1.  SYN-SENT    --> <seq=100><CTL=SYN>               --> SYN-RECEIVED

  2.  ESTABLISHED <-- <seq=300><ack=101><CTL=SYN,ACK>  <-- SYN-RECEIVED

  3.  ESTABLISHED --> <seq=101><ack=301><CTL=ACK>       --> ESTABLISHED

      
At this point, both the client and server have received an acknowledgment of the connection. 
The steps 1, 2 establish the connection parameter (sequence number) 
for one direction and it is acknowledged. 
The steps 2, 3 establish the connection parameter (sequence number) 
for the other direction and it is acknowledged. With these, a full-duplex communication is established.

2.什么是死锁?

由于资源争夺所发生的死锁,会导致程序变成阻塞的状态。
A获取了一个锁,B也获取了一个锁,A要去获取B的锁,B也要去获取A的锁,就会造成死锁。

3.基于threading模块实现将foo函数和bar函数并发运行并计算总共运行时间

import time
import threading

def foo():
    print("foo开始")
    time.sleep(3)
    print("foo结束")

def bar():
    print("bar开始")
    time.sleep(5)
    print("bar结束")

    
func_list = [foo,bar]
thread_list = []
start_time = time.time()

for func in func_list:
    t = threading.Thread(target=func)
    t.start()
    thread_list.append(t)


for t in thread_list:
    t.join()

end_time = time.time()
print(end_time-start_time)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值