Giter Club home page Giter Club logo

ntyco's Introduction

My Working Thought

struct Offering {
  void *doc;
  void *code;
  void *paper;
  void *video;
  void *ppt;
  void *question;
};

Project * getExcellentOpenSource(CodeWorld *w) {
  
  if (your.interest) {
    if (email("[email protected]") || submit(issue)) {
      return getYourExcellentOpenSource();
    }
  }
  return top(w->star) == NULL ? top(w->fork) : top(w->star);
}

struct Offering * produce(Project *p) {

  Offering *o = malloc(sizeof(struct Offering));
  o->doc = arrangeDocument(p);
  o->code = produceExampleCode(p);
  o->video = produceVideo(p);
  o->paper = arrangePaper(p); //https://www.usenix.org/
  o->ppt = arrangePPTpdf(p);
  o->question = arrangeQuestionList(p);
  
  return o;
}

void produceRepo(struct Offering *o) {
  setRepoOrg0voice(o); // https://github.com/0voice
  free(o);
}

int main() {
  CodeWorld world;  // network, OS, storage, SDN, virtual, kernel, RISC-V, etc. (code with c/c++)
  
#pragma omp parallel num_threads(worker_nums)  
  {
    while(1) {
      Project *p = getExcellentOpenSource(world);
      //Project: dpdk, rocksdb, spdk, vpp, ovs, userstack, coroutine, virtio, nginx, redis, zmq, bpf/ebpf, io_uring, etc.

      struct Offering *o = produce(p);
      produceRepo(o);
    }
  }
}

ntyco's People

Contributors

piaodazhu avatar wangbojing avatar zhiyong0804 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ntyco's Issues

nty_close happened.

nty_server_mulcore: nty_schedule.c:172: nty_schedule_sched_wait: Assertion `co_tmp == ((void *)0)' failed.
Aborted (core dumped)

nty_server.c:117 传入了一个栈变量

nty_coroutine_create(&read_co, server_reader, &cli_fd) cli_fd 为栈变量,复制给co->arg 栈对象的地址不会有问题么?

void server(void *arg) {

	unsigned short port = *(unsigned short *)arg;
	free(arg);

	int fd = nty_socket(AF_INET, SOCK_STREAM, 0);
	if (fd < 0) return ;

	struct sockaddr_in local, remote;
	local.sin_family = AF_INET;
	local.sin_port = htons(port);
	local.sin_addr.s_addr = INADDR_ANY;
	bind(fd, (struct sockaddr*)&local, sizeof(struct sockaddr_in));

	listen(fd, 20);
	printf("listen port : %d\n", port);

	struct timeval tv_begin;
	gettimeofday(&tv_begin, NULL);

	while (1) {
		socklen_t len = sizeof(struct sockaddr_in);
		int cli_fd = nty_accept(fd, (struct sockaddr*)&remote, &len);
		if (cli_fd % 1000 == 999) {

			struct timeval tv_cur;
			memcpy(&tv_cur, &tv_begin, sizeof(struct timeval));
			
			gettimeofday(&tv_begin, NULL);
			int time_used = TIME_SUB_MS(tv_begin, tv_cur);
			
			printf("client fd : %d, time_used: %d\n", cli_fd, time_used);
		}
		printf("new client comming\n");

		nty_coroutine *read_co;
		// arg 传入一个栈上变量?
		nty_coroutine_create(&read_co, server_reader, &cli_fd);
	}
}

nty_poll_inner happend

nty_socket.c: nty_poll_inner: Calling nty_poll_inner function to pass in more than one FD will cause the abort problem.

debug info:
nty_schedule_sched_wait (co=0x55555575e260, fd=6, events=28, timeout=1) at /root/clang/core/nty_schedule.c:152
152 if (co->status & BIT(NTY_COROUTINE_STATUS_WAIT_READ) ||
(gdb) n
155 co->id, co->fd, co->status);
(gdb)
154 printf("Unexpected event. lt id %"PRIu64" fd %"PRId32" already in %"PRId32" state\n",
(gdb)
Unexpected event. lt id 0 fd 5 already in 9 state
156 assert(0);

stack info:
#0 nty_schedule_sched_wait (co=0x55555575e260, fd=6, events=28, timeout=1) at /root/clang/core/nty_schedule.c:156
#1 0x0000555555555fa1 in nty_poll_inner (fds=0x555555762f30, nfds=2, timeout=1) at /root/clang/sample/nty_client_mult.c:91
#2 0x0000555555556179 in init_client () at /root/clang/sample/nty_client_mult.c:134
#3 0x00005555555561bc in client (arg=0x0) at /root/clang/sample/nty_client_mult.c:143
#4 0x0000555555556360 in _exec (lt=0x55555575e260) at /root/clang/core/nty_coroutine.c:116
#5 0x0000000000000000 in ?? ()

关于多线程协程

请问如果要支持在多线程环境中使用协程,有什么思路吗,是不是可以在主线程分发任务给不同线程,然后每个线程单独开一个协程池进行任务处理。
但是协程在线程之间转移会不会有问题,主线程accept了一个连接,并转移到了其他线程,因为我看到scheduler是用pthread_key_t标识的。

有个疑问

例如下面这种阻塞代码怎么调度呢?

f1(){
        sleep(99999999)
}
f2(){
        println("hello")
}

main(){
        f1()
        f2()
}

与lthrad的差异

我阅读了一下NtyCo的源代码,发现其核心代码与lthread很相似,请问一下NtyCo借用了lthread的哪些内容,做了哪些改进和优化?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.