37signals也能down成这样 ?

今天想37signals上去看看我的todolist来着,没想到看到了下面的页面:

[img]http://pupi.iteye.com/upload/picture/pic/7109/033eb71b-ab38-3cda-9670-a29c5ab5e586.jpg?1200675734[/img]

现在正是北美的周五工作时间,估计那么多saas的用户要疯掉了。

另外,也说明b/s结构的应用出错的机率还是不低的。因为受到太多东西的制约。好像javaeye也曾经因为病毒而停过1,2天机的。
### down_write_killable: Linux Kernel Synchronization Mechanism `down_write_killable` is a function in the Linux kernel that provides a mechanism for acquiring a write lock on a reader-writer semaphore. This function is particularly useful in scenarios where the caller might want to handle interruptions during the lock acquisition process. If an interrupt occurs while waiting for the lock, the function returns `-EINTR`, allowing the caller to decide how to proceed[^1]. The `down_write_killable` function operates within the context of the `rw_semaphore` structure, which is defined in the `include/linux/rwsem.h` header file. The structure includes several fields such as `count`, `wait_list`, and `wait_lock`, which are crucial for managing the state of the semaphore and coordinating between readers and writers[^1]. Here is a simplified code snippet demonstrating the usage of `down_write_killable`: ```c #include <linux/rwsem.h> struct rw_semaphore my_rwlock; void initialize_rwlock(void) { init_rwsem(&my_rwlock); } int try_acquire_write_lock(void) { int ret = down_write_killable(&my_rwlock); if (ret == -EINTR) { // Handle interruption printk(KERN_INFO "Lock acquisition interrupted\n"); } else { // Lock acquired successfully printk(KERN_INFO "Write lock acquired\n"); } return ret; } void release_write_lock(void) { up_write(&my_rwlock); printk(KERN_INFO "Write lock released\n"); } ``` In this example: - The `init_rwsem` function initializes the `rw_semaphore`. - The `down_write_killable` function attempts to acquire the write lock, returning `-EINTR` if interrupted. - The `up_write` function releases the write lock after its usage. #### Key Aspects of `down_write_killable` - **Interruptibility**: Unlike `down_write`, which blocks indefinitely until the lock is acquired, `down_write_killable` allows the caller to handle interruptions gracefully[^1]. - **Concurrency Control**: It ensures that only one writer can hold the lock at any given time, while multiple readers can access the resource simultaneously. - **Performance Considerations**: On single-processor systems, operations like `smp_mb()` act as compile-time barriers to ensure proper instruction ordering without interfering with CPU behavior[^2]. #### Memory Barriers and Spinlocks In multi-processor environments, memory barriers and spinlocks play a critical role in ensuring data consistency. For instance, inserting `mmiowb()` before releasing a spinlock guarantees that all previous writes complete before unlocking[^3]. This prevents potential race conditions when multiple CPUs access shared resources. #### Signals and Synchronization Signals in the Linux kernel are handled asynchronously by the kernel itself. When a signal is sent to a process, it is queued until the process enters the kernel mode, at which point the appropriate signal handler is invoked[^4]. This mechanism complements synchronization primitives like `down_write_killable` by allowing processes to respond to external events even while waiting for locks.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值