Skip to content

Instantly share code, notes, and snippets.

View baixiangcpp's full-sized avatar
:octocat:
Focusing

baixiangcpp baixiangcpp

:octocat:
Focusing
View GitHub Profile
@baixiangcpp
baixiangcpp / installing-pintos
Last active May 28, 2022 19:15
installing pintos
apt install vim unzip make gcc clang binutils-dev qemu-system-x86 fzf cgdb python wget git autotools-dev automake flex texinfo libreadline6-dev
/test/test/group0-master/src/utils/pintos-gdb:
GDBMACROS=/test/test/group0-master/src/misc/gdb-macros
upgrage cgdb
OK
@baixiangcpp
baixiangcpp / TimerWheel.cpp
Created January 22, 2019 08:45
A timer implemented with time wheel
#include <functional>
#include <vector>
#include <iostream>
#include <algorithm>
#include <sys/epoll.h>
#include <sys/time.h>
#include <unistd.h>
class Timer
{
@baixiangcpp
baixiangcpp / TimerPriorityQueue.cpp
Created January 22, 2019 06:35
A timer implemented with priority queue
#include <functional>
#include <iostream>
#include <algorithm>
#include <sys/epoll.h>
#include <sys/time.h>
#include <unistd.h>
#include <queue>
#include <vector>
@baixiangcpp
baixiangcpp / helloworld.c
Created December 6, 2018 16:22
A libevent helloworld not using changelist
#include <event2/event.h>
#define BUF_SIZE 1024
void onError(const char *reason)
{
perror(reason);
exit(EXIT_FAILURE);
}
void read_cb(int fd,short events,void* arg)
@baixiangcpp
baixiangcpp / helloworld.c
Created August 31, 2018 16:17
A libevent helloworld using changelist
#include <event2/event.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define BUF_SIZE 1024
void onError(const char *reason)
{
perror(reason);
exit(EXIT_FAILURE);
@baixiangcpp
baixiangcpp / Makefile
Created August 24, 2018 16:24
Makefile for seafile client
version = 6.2.4
THREADS = 4
HOST_OS = MINGW32
JANSSONDIR = jansson-2.11
LIBEVENTDIR = libevent-2.1.8-stable
LIBSEARPCDIR = libsearpc-3.1-latest
SEAFILEDIR = seafile-$(version)
@baixiangcpp
baixiangcpp / install-seafile-env.sh
Created August 24, 2018 14:20
Seafile client cross compile environment
echo "Install dependent library ..."
libs=(sed git mingw32-curl intltool vala libtool automake make cmake \
mingw32-qt5-qtbase-devel mingw32-qt5-qttools-tools mingw32-pkg-config \
unzip libuuid-devel libcurl-devel openssl-devel qt5-qtbase-devel \
make qt5-qttools-devel doxygen wget sqlite-devel mingw32-qt5-qttools \
mingw32-qt5-qmake)
sudo dnf install ${libs[@]} -y
@baixiangcpp
baixiangcpp / reactor-demo.c
Last active February 26, 2019 13:24
A simple libevent-like reactor demo base on epoll api
/*
* @Author: baixiangcpp@gmail.com
* @Date: 2018-07-28 11:04:52
* @Last Modified by: baixiangcpp@gmail.com
* @Last Modified time: 2018-07-28 11:07:04
* @usage: An implementation of reactor design patterns base on epoll.
*/
#include <stdio.h>
#include <stdlib.h>
@baixiangcpp
baixiangcpp / epoll-starvation.c
Created August 1, 2018 15:29
file-descriptor starvation when using epoll edge-triggered notification
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <strings.h>
#include <errno.h>
#include <netinet/in.h>