Turn off the rightmost set bit

reference: 

http://www.geeksforgeeks.org/turn-off-the-rightmost-set-bit/


Problem Definition:

Write a C function that unsets the rightmost set bit of an integer.


Solution:

Let the input number be n. n-1 would have all the bits flipped after the rightmost set bit (including the set bit). So, doing n&(n-1) would give us the required result.


Code:

/* unsets the rightmost set bit of n and returns the result */
int fun(unsigned int n)
{
  return n&(n-1);
}    


Full state block ack operation Under full state block ack, the recipient maintains an ack state scoreboard for each block ack session. The scoreboard records the ack state of up to 64 MSDUs. When fragmenta tion is used each MSDUmaybefragmentedinupto16 fragments, thus the scoreboard is an up to 64 entry by 16-bit array. A recipient implementation with limited memory may constrain the extent of the array by setting the BufferSize parameter in the ADDBA Response. The MSDU sequence number is a 12-bit value, thus the scoreboard represents a windowinthesequencenumberspaceof4096values.Thescoreboardwindowisdefined by a beginning sequence number WinStart, an ending sequence number WinEnd, and an extent WinSize. With the establishment of the block ack session the scoreboard is initialized with WinStart set to the starting sequence number provided in the ADDBA request. When a QoS Data frame arrives, if the sequence number falls within the space represented by the scoreboard then the recipient will index the scoreboard using the data frame’s sequence number (SN) and record its correct receipt. If the SN is outside the space represented by the scoreboard but within the range WinEnd to WinStart + 211 (half the sequence number space) then the recipient will shift the scoreboard to the right until it includes the new sequence number on the rightmost edge of its window. WhenaBARarrives, the scoreboard window is shifted to the right so that WinStart is equal to the SSN provided in the BAR frame and a BA response is returned with the contents of the scoreboard. Motivation for partial state block ack Withthe original block ack mechanisms, it is required that the scoreboard state persist for the duration of the block ack session. This burdens the recipient implementation with the need to maintain state for all active block ack sessions and, in practice, with the low latency required to produce a BA in response to a BAR, this means using expensive on chip memory. Withthe 802.11n amendment the rules are relaxed so that on-chip memory reserved for block ack state may be reused by different block ack sessions. The state memory effectively serves as a cache, storing the state of the most recently active block ack session. The newer rules are referred to as partial state block ack and are fully backward compatible with the original full state block ack rules. To understand the motivation for the change consider a typical implementation illustrated in Figure 9.16. Under immediate BA, when the recipient receives a BAR or an aggregate frame containing QoS Data frames with Normal Ack policy, the recipient must transmit a BAResponseframeSIFSafterreceiving the BARoraggregateQoSData frame. With decode latencies on the receive path and encode latencies on the transmit path, there is little time available to locate the appropriate state information and form the BAResponse. This largely necessitates on-chip storage of the block ack scoreboard that will be returned in the BA Response. The other major function in the block ack mechanism is the reassembly and reorder function, which reassembles complete MSDUs and forwards them in order to the higher Typical functional split for immediate block ack implementation in recipient station. layers. This function is not time critical and requires a large buffer for storing packets during the reorder and reassembly process and as such is typically implemented in the system hosting the network interface. Thenewpartial state rules do not affect the reorder and reassembly process, but reduce the resource requirements in the network interface for storing the block ack scoreboard. A reorder buffer is still required for each block ack session, but since this is typically stored in the host memory it is relatively cheap. Much less memory is required on-chip to store the block ack scoreboard since the same memory can be reused for multiple block ack sessions
08-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值