3,手写strcpy,memcpy,memmove函数;
2,线程同步几种方式:
互斥锁,信号量,临界区
1,实现一个vector,是1.5还是2倍?各有什么优缺点:
(1)1.5倍优势:可以重用之前分配但是释放的内存;
(2)2倍劣势:每次申请的内存都不可以重用;
0,线程安全的单例模式
class Singleton{ private: static pthread_mutex_t mtx; static Singleton* instance; Singleton(){} ~Singleton(){} public: static Singleton* getInstance(){ if(instance == NULL){ pthread_mutex_lock(mtx); if(instance == NULL){ instance = new Singleton(); } pthread_mutex_unlock(mtx); } return instance; } }; pthread_mutex_t Singleton::mtx = PTHREAD_MUTEX_INITIALIZER; Singleton Singleton::instance = NULL;