Vmware + Centos7 + NAT 方式连接公网

使用gdb调试时, Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7.x86_64, 需要虚拟机联网更新。 环境: 操作系统:Windows 10 Vmware: 12.5.5 build-5234757 Centos 7 : Linux centosgpt 5.2.0-rc2 可以使用自动获取ip或者配置静态地址两种方式: DHCP模式: 1 VMware 配置: VMware中使用动态分配IP的需要勾选 编辑->虚拟网络编辑器->VMnet信息中->使用本地DHCP服务将IP地址分配给虚拟机 2 主动获取动态IP, 使用dhclient动态获取IP , 增加-v参数显示相关日志。 sudo dhclient –v 设置开机自动处理服务: 增加文件 /etc/init.d/net-autostart #!/bin/bash # Solution for No Internet Connection from VMware # ### BEGIN INIT INFO # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO dhclient -v 给文件增加权限 chmod 755 net-autostart 增加系统服务 chkconfig --add net-autostart ...

2019-06-06 · 1 min · 106 words

LeetCode – Rotate List

题目: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->NULL Explanation: rotate 1 steps to the right: 5->1->2->3->4->NULL rotate 2 steps to the right: 4->5->1->2->3->NULL Example 2: Input: 0->1->2->NULL, k = 4 Output: 2->0->1->NULL Explanation: rotate 1 steps to the right: 2->0->1->NULL rotate 2 steps to the right: 1->2->0->NULL rotate 3 steps to the right: 0->1->2->NULL rotate 4 steps to the right: 2->0->1->NULL ...

2019-06-03 · 1 min · 178 words

Linux下实现一个系统调用

环境: 环境: cenos7 kernel: 3.10.0-862.el7.x86_64 gcc: gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 新版内核: linux-5.2-rc2 准备: 安装相关软件: yum install make automake vim perl openssl* elfutils-libelf- curl gcc wget flex git build-essential ncurses-devel xz-utils libssl-dev bc flex libelf-dev bison elfutils-libelf-devel -y 下载内核源码并解压: tar -xf linux-5.2-rc2.tar.gz 编写系统调用: 新增系统调用表条目: cp syscall_64.tbl syscall_64.tbl.backup linux-5.2-rc2/arch/x86/entry/syscalls/syscall_64.tbl 新增下面一条 + 434 common iadd_test __x64_sys_iadd_test 其中434为新增的调用号 增加函数声明 linux-5.2-rc2/include/linux/syscalls.h:新增一行 asmlinkage long sys_iadd_test(int one, int two); 新增系统调用定义 kernel/linux-5.2-rc2/fs/iadd_test.c #include <linux/printk.h> #include <linux/syscalls.h> #include "internal.h" long do_iadd(const int one, const int two ) { long sum = 0L; sum = one + two; return sum; } SYSCALL_DEFINE2(iadd_test, const int, one, const int, two) { printk("call iaddtest..."); return do_iadd(one, two); } 修改Makfile 增加iadd_test.o ...

2019-06-02 · 2 min · 342 words

什么是RCU

这篇文章What is RCU, Fundamentally? 作者: Paul E. McKenney, IBM Linux Technology Center , Jonathan Walpole, Portland State University Department of Computer Science RCU : read-copy-update (RCU) is a synchronization mechanism based on mutual exclusion. 对于RCU机制保护下的数据, 读数据不需要获得任何锁或者很小代价的开销就可以访问, 对于写者需要先拷贝一份副本, 然后修改,最后使用一个回调(callback)机制在适当的时机把指向原来数据的指针重新指向新的被修改的数据。这个时机就是所有引用该数据的CPU都退出对共享数据的操作。 本文主要介绍RCU同步机制的三个部分: 针对插入操作的发布订阅机制; 针对删除操作的等待预先启动读者完成机制; 维护最新更新对象多个版本; 文章中以链表为例介绍了RCU处理过程: 删除情况下保持多版本: 1 struct foo { 2 struct list_head list; 3 int a; 4 int b; 5 int c; 6 }; 7 LIST_HEAD(head); 8 9 /* . . . */ 10 11 p = search(head, key); 12 if (p != NULL) { 13 list_del_rcu(&p->list); 14 synchronize_rcu(); 15 kfree(p); 16 } 找到要删除的节点 ...

2019-06-02 · 1 min · 198 words

ORA-01795, limit on in clause

遇到问题: 实施过程中 oracle 报错 ORA-01795, limit on in clause, 发现是SQL IN 语句中的条件从ZZ表中拼接而成。 SELECT * FROM T1 WHERE T1.VAL in ('1111', '2222', ... more than 1000 here ); 相关调整方案: -- 1 子查询1 SELECT VAL FROM T1 WHERE T1. VAL IN ( SELECT VAL FROM T2 ); -- 2. 子查询2 SELECT VAL FROM ( SELECT DISTINCT VAL FROM T2 ) B WHERE B.VAL=A.VAL -- 3. JOIN SELECT VAL FROM ( SELECT DISTINCT VAL FROM T2 ) B JOIN A ON B.VAL=A.VAL -- 4. EXISTS SELECT VAL FROM T1 A WHERE EXISTS ( SELECT 1 FROM T2 WHERE A.VAL=VAL ); 使用IN还是EXISTS 以下引用oracle ASK TOM 中描述: ...

2019-05-29 · 1 min · 146 words

LeetCode-Copy List with Random Pointer

题目: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. Example 1: Input: {"$id":"1","next":{"$id":"2","next":null,"random":{"$ref":"2"},"val":2},"random":{"$ref":"2"},"val":1} Explanation: Node 1's value is 1, both of its next and random pointer points to Node 2. Node 2's value is 2, its next pointer points to null and its random pointer points to itself. Note: ...

2019-05-28 · 2 min · 371 words

linux内核中的进程列表

Linux链表数据结构及相关操作 定义 /include/linux/types.hstruct list_head { struct list_head *next, *prev; };与响应的结构组成双向链表。 初始化 /include/linux/list.h#define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) 方法 插入 static inline void list_add(struct list_head *new, struct list_head *head)static inline void list_add_tail(struct list_head *new, struct list_head *head) 删除 static inline void list_del(struct list_head *entry) 替换 static inline void list_replace(struct list_head *old, struct list_head *new) 交换 static inline void list_swap(struct list_head *entry1, struct list_head *entry2) 删除 static inline void list_move(struct list_head *list, struct list_head *head) 遍历 #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) 获取节点某一成员 #define list_entry(ptr, type, member) \ container_of(ptr, type, member) 以上是基于2.4内核版本的宏, 2.6版本后引入RCU新的锁机制,相关宏定义后新增_rcu. ...

2019-05-26 · 3 min · 535 words

Netflix Blog- Netflix Python技术的使用

这篇文章 Python at Netflix 是出自 Netflix Technology Blog 本文主要介绍python在Netflix各个组内的应用 Open Connect: Netflix搭建的全球CDN网络,python有广泛应用。 Demand Engineering: 数值分析类:numpy, scipy AWS SDK:boto3 Web 框架: Flask 队列: RQ(Redis queue) 轻量级IDE: bpython 编辑工具: Jupyter Notebooks, nteract Data Explorer: visualization tools Data FrameWork:Semiotic CORE: 统计学数值分析类:numpy, scipy ruptures pandas Monitoring, alerting and auto-remediation: Spectator : metris的客户端 客户端: Spectator Python client Winston and Bolt : Web 框架: Flask WSGI http server: Gunicorn Flask Rest APIs 插件: Flask-RESTPlus Information Security: 安全监控: Security Monkey SSH资源保护: Bless TLS证书生成:Lemur. AWS安全部署(权限最小化): Aardvark and Repokid 数据取证 : Diffy Prism, Lanius Personalization Algorithms: 深度神经网络学习: TensorFlow Keras PyTorch Gradient Boosted Decision Trees : XGBoost LightGBM 其他相关科学运算类:numpy, scipy pandas sklearn matplotlib cvxpy Machine Learning Infrastructure: ML Libraries: R Project TensorFlow XGBoost ...

2019-05-21 · 2 min · 238 words

LeetCode – Flatten a Multilevel Doubly Linked List

题目: You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example below. Flatten the list so that all the nodes appear in a single-level, doubly linked list. You are given the head of the first level of the list. ...

2019-05-20 · 1 min · 213 words

python多线程方式扫描开放端口

使用python多线程方式扫描某台机器开放端口 import socket import time import threading from queue import Queue socket.setdefaulttimeout(0.25) print_lock = threading.Lock() target = '127.0.0.1' def portscan(port): s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: con = s.connect_ex((target,port)) if con == 0: with print_lock: print('port', port, 'is open') con.close() except: pass def threader(): while True: worker = q.get() portscan(worker) q.task_done() q = Queue() startTime = time.time() for x in range(1000): t = threading.Thread(target=threader) t.daemon = True t.start() for worker in range(1,65536): q.put(worker) q.join() print('Time taken:', time.time()-startTime) 参考: ...

2019-05-20 · 1 min · 77 words