太一のコードの読み方メモ
全体として太一が感覚的に実践している事を論理的に説明しようと試みている為、
説明の粒度が適切でなかったり一貫性が無いように見える部分があるかもしれない。
普段やっているけども書ききれていない事も多分きっとある。
コードを読むとは何か
- コードを嗜む
- コードを学ぶ
- 武器を手に入れる
wait-free/lock-free/obstruction-freeの定義について | |
▲全てに共通する概念 | |
スレッドが他のスレッドの進行を禁止する事がないので、どれかのスレッドが | |
ロックを確保したままプリエンプションなどで全体の処理が停止する事態が発生しな | |
い。 | |
これは必ずしもロックベースのアルゴリズムより高速であることを意味し | |
ない(現にロックの方が早い場合もある | |
wait-freeが一番強い条件で、それを弱める度に |
lld/build$ cmake -G Ninja .. | |
CMake Error at CMakeLists.txt:6 (string): | |
string sub-command REGEX, mode MATCH needs at least 5 arguments total to | |
command. | |
-- LLD version: | |
CMake Error at CMakeLists.txt:10 (string): | |
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to | |
command. |
#ifndef LOCKFREE_QUEUE | |
#define LOCKFREE_QUEUE | |
#include "atomics.h" | |
#include <unistd.h> // usleep | |
#include <stdlib.h> // rand | |
namespace lockfree{ | |
template<typename T> |
全体として太一が感覚的に実践している事を論理的に説明しようと試みている為、
説明の粒度が適切でなかったり一貫性が無いように見える部分があるかもしれない。
普段やっているけども書ききれていない事も多分きっとある。
#define _GNU_SOURCE 1 | |
#include <sched.h> // sched_setaffinity | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <limits.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#include <sys/time.h> |
# config valid only for current version of Capistrano | |
lock "3.8.2" | |
set :application, "my_application" | |
set :repo_url, "git@github.com:kumagi/my_application" | |
set :branch, 'master' | |
set :deploy_to, "/opt/my_application" | |
set :format, :airbrussh |
Sign up Link
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
#include <papi.h> | |
#include <stdio.h> | |
#include <iostream> | |
#include <vector> | |
int main() { | |
std::vector<int> Events = { | |
PAPI_BR_MSP, | |
PAPI_BR_NTK, | |
PAPI_TLB_IM |
#include <sys/socket.h> | |
#include <thread> | |
#include <iostream> | |
#include <unistd.h> | |
#include <netinet/in.h> | |
#include <arpa/inet.h> | |
int main() { | |
sockaddr_in addr; | |
addr.sin_family = AF_INET; | |
addr.sin_port = htons(12345); |
0 is empty! so first insert to 0 | |
1 is empty! so first insert to 1 | |
extend to 4 ! | |
rehash key:0 into slot:0 | |
rehash key:1 into slot:1 | |
2 is empty! so first insert to 2 | |
3 is empty! so first insert to 3 | |
extend to 8 ! | |
rehash key:0 into slot:0 | |
rehash key:1 into slot:1 |