int task_main(void* args) { int i; int eid; int size; int rts; char* ubuf; if (argc < 4) { printf("usage: thr_sender <connect-to> <msg-size> <roundtrips>\n"); return 0; } size = atoi(argv[2]); rts = atoi(argv[3]); BUG_ON((eid = sp_endpoint(SP_REQREP, SP_REQ)) < 0); BUG_ON(sp_connect(eid, argv[1]) < 0); BUG_ON(sp_send(eid, ualloc(size)) != 0); for (i = 0; i < rts; i++) { BUG_ON(sp_send(eid, ualloc(size)) != 0); } BUG_ON(sp_recv(eid, &ubuf) != 0); ufree(ubuf); sp_close(eid); return 0; }
static void init_ulibc (void) { if (!(_dyn_mem_pool = (char *) ualloc (CONFIG_UDYNAMIC_MEMORY))) _exit (-1); if (!init_memory_pool (CONFIG_UDYNAMIC_MEMORY, _dyn_mem_pool)) _exit (-1); init_lang_supp (); }
static void init_ulibc (void) { if (!(_dyn_mem_pool = (char *) ualloc (CONFIG_UDYNAMIC_MEMORY))) _exit (-1); if (!init_memory_pool (CONFIG_UDYNAMIC_MEMORY, _dyn_mem_pool)) _exit (-1); printf("\n Init ulibc memory finished.\n"); // init_lang_supp (); }
static VALUE rb_sp_send (VALUE self, VALUE eid, VALUE msg) { int _eid = FIX2INT (eid); int rc; VALUE rb_hdr = 0; char *hdr = 0; char *ubuf = ualloc (RSTRING (msg)->len); memcpy (ubuf, RSTRING (msg)->ptr, usize (ubuf)); /* How can i checking the valid rb_values, f*****g the ruby extension here */ if ((rb_hdr = rb_iv_get (msg, "@hdr")) != 4) { Data_Get_Struct (rb_hdr, char, hdr); if (hdr) uctl (hdr, SCOPY, ubuf); } if ((rc = sp_send (_eid, ubuf))) ufree (ubuf); return INT2FIX (rc); }
/* * You may redistribute this program and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation, * either version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* initialize */ if (unreaped == 0) { unreaped = ualloc (unreaped, 1); unreaped[0].pid = 0; n = 1; } for (i = 0; unreaped[i].pid; i++) if (unreaped[i].pid == pid) { *status = unreaped[i].status; while (unreaped[i].pid) { unreaped[i] = unreaped[i+1]; i++; } n--; return pid;