예제 #1
0
static u32 remove_bp(void *mem)
{
    struct bp_entry *e = p_bpentries;
    struct bp_entry *f = NULL;

    if(!e) return 0;
    if(e->address==mem) {
        p_bpentries = e->next;
        f = e;
    } else {
        for(; e->next; e=e->next) {
            if(e->next->address==mem) {
                f = e->next;
                e->next = f->next;
                break;
            }
        }
    }
    if(!f) return 0;

    *(f->address) = f->instr;
    f->instr = 0xffffffff;
    f->address = NULL;

    DCStoreRangeNoSync((void*)((u32)mem&~0x1f),32);
    ICInvalidateRange((void*)((u32)mem&~0x1f),32);
    _sync();

    return 1;
}
예제 #2
0
void
game_usermsg(struct service* s, int id, void* msg, int sz) {
    struct game* self = SERVICE_SELF;
    struct gate_message* gm = msg;
    assert(gm->c);
    UM_CAST(UM_BASE, um, gm->msg);
    switch (um->msgid) {
    case IDUM_GAMELOGIN:
        _login(self, gm->c, um);
        break;
    case IDUM_GAMELOGOUT:
        _logout(self, gm->c, true, true);
        break;
    case IDUM_GAMELOADOK:
        _loadok(self, gm->c);
        break;
    case IDUM_GAMESYNC:
        _sync(self, gm->c, um);
        break;
    case IDUM_ROLEPRESS:
        _role_press(self, gm->c, um);
        break;
    case IDUM_USEITEM:
        _use_item(self, gm->c, um);
        break;
    }
}
예제 #3
0
void neam::cr::storage::truncate()
{
  if (mapped_file)
    mapped_file->clear();
  else
    mapped_file = new std::map<std::string, raw_data>;
  _sync();
}
 pplx::task<void> basic_cloud_page_blob_ostreambuf::commit_blob()
 {
     if (m_blob_hash_provider.is_enabled())
     {
         auto this_pointer = std::dynamic_pointer_cast<basic_cloud_page_blob_ostreambuf>(shared_from_this());
         return _sync().then([this_pointer] (bool) -> pplx::task<void>
         {
             this_pointer->m_blob->properties().set_content_md5(this_pointer->m_blob_hash_provider.hash());
             return this_pointer->m_blob->upload_properties_async(this_pointer->m_condition, this_pointer->m_options, this_pointer->m_context);
         });
     }
     else
     {
         return _sync().then([] (bool)
         {
         });
     }
 }
예제 #5
0
bool neam::cr::storage::_write_to_file(const std::string &name, char *memory, size_t size)
{
  if (!mapped_file)
    mapped_file = new std::map<std::string, raw_data>;
  mapped_file->erase(name);
  mapped_file->emplace(name, (raw_data(size, reinterpret_cast<int8_t *>(memory), neam::force_duplicate)));

  _sync();
  return true;
}
예제 #6
0
파일: filesys.c 프로젝트: ljalves/FUZIX
uint16_t i_alloc(uint16_t devno)
{
    staticfast fsptr dev;
    staticfast blkno_t blk;
    struct dinode *buf;
    staticfast uint16_t j;
    uint16_t k;
    unsigned ino;

    if(baddev(dev = getdev(devno)))
        goto corrupt;

tryagain:
    if(dev->s_ninode) {
        if(!(dev->s_tinode))
            goto corrupt;
        ino = dev->s_inode[--dev->s_ninode];
        if(ino < 2 || ino >=(dev->s_isize-2)*8)
            goto corrupt;
        --dev->s_tinode;
        return(ino);
    }
    /* We must scan the inodes, and fill up the table */

    _sync();           /* Make on-disk inodes consistent */
    k = 0;
    for(blk = 2; blk < dev->s_isize; blk++) {
        buf = (struct dinode *)bread(devno, blk, 0);
        for(j=0; j < 8; j++) {
            if(!(buf[j].i_mode || buf[j].i_nlink))
                dev->s_inode[k++] = 8*(blk-2) + j;
            if(k==FILESYS_TABSIZE) {
                brelse(buf);
                goto done;
            }
        }
        brelse(buf);
    }

done:
    if(!k) {
        if(dev->s_tinode)
            goto corrupt;
        udata.u_error = ENOSPC;
        return(0);
    }
    dev->s_ninode = k;
    goto tryagain;

corrupt:
    kputs("i_alloc: corrupt superblock\n");
    dev->s_mounted = 1;
    udata.u_error = ENOSPC;
    return(0);
}
예제 #7
0
//this method is called from client thread!!! (not from eibhandler thread)
void CEIBHandler::Write(const CCemi_L_Data_Frame& data, BlockingMode mode, JTCMonitor* optional_mon)
{
	do
	{
		//put the frame (that about the be sent) in the Handler queue and wake him up
		//note: writing to the queue is synced
		JTCSynchronized _sync(*this);
		KnxElementQueue elem;
		elem._frame = data;
		elem._mode = mode;
		elem._optional_mon = optional_mon;
		_buffer.Write(elem);
		this->notify();
	}while(0);

	if((mode == WAIT_FOR_CONFRM || mode == WAIT_FOR_ACK) && optional_mon != NULL){
		//block the client thread till we got proper response from the KnxNet/IP device
		JTCSynchronized sync(*optional_mon);
		optional_mon->wait();
	}
}
예제 #8
0
파일: rdcli.c 프로젝트: kbumsik/RIOT
static int _update_remove(unsigned code, gcoap_resp_handler_t handle)
{
    coap_pkt_t pkt;

    if (_rd_loc[0] == 0) {
        return RDCLI_NORD;
    }

    /* build CoAP request packet */
    int res = gcoap_req_init(&pkt, buf, sizeof(buf), code, _rd_loc);
    if (res < 0) {
        return RDCLI_ERR;
    }
    coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
    ssize_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);

    /* send request */
    gcoap_req_send2(buf, pkt_len, &_rd_remote, handle);

    /* synchronize response */
    return _sync();
}
예제 #9
0
void CEIBHandler::RunEIBWriter()
{
	KnxElementQueue msg2write;
	CEIBInterface& iface = CEIBServer::GetInstance().GetEIBInterface();

	JTCSynchronized sync(_wait_mon);
	//sync the reading from the queue
	JTCSynchronized _sync(*this);

	while (!_stop)
	{
		START_TRY
			//if we have a packet waiting in the queue then forward it to the KNXNet/IP device
			if(_buffer.Read(msg2write))
			{
				iface.Write(msg2write);
			}

			if(_pause)
			{
				LOG_DEBUG("EIB Writer suspended.");
				_wait_mon.wait();
				LOG_DEBUG("EIB Writer resumed.");
			}

			//release the lock untill the buffer will be filled up or 1 sec passed (to give change to the pause feature)
			this->wait(1500);
		END_TRY_START_CATCH_JTC(e)
			LOG_ERROR("JTC Error: %s",e.getMessage());
		END_TRY_START_CATCH(ex)
			LOG_ERROR("Exception at EIB Writer handler: %s",ex.what());
		END_TRY_START_CATCH_ANY
			LOG_ERROR("Unknown Exception at EIB Writer handler");
		END_CATCH
	}
}
예제 #10
0
파일: rdcli.c 프로젝트: kbumsik/RIOT
static int _discover_internal(const sock_udp_ep_t *remote,
                              char *regif, size_t maxlen)
{
    coap_pkt_t pkt;

    /* save pointer to result buffer */
    _regif_buf = regif;
    _regif_buf_len = maxlen;

    /* do URI discovery for the registration interface */
    int res = gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_GET,
                             "/.well-known/core");
    if (res < 0) {
        return RDCLI_ERR;
    }
    coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
    gcoap_add_qstring(&pkt, "rt", "core.rd");
    size_t pkt_len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
    res = gcoap_req_send2(buf, pkt_len, remote, _on_discover);
    if (res < 0) {
        return RDCLI_ERR;
    }
    return _sync();
}
예제 #11
0
static u32 insert_bp(void *mem)
{
    u32 i;
    struct bp_entry *p;

    for(i=0; i<GEKKO_MAX_BP; i++) {
        if(bp_entries[i].address == NULL) break;
    }
    if(i==GEKKO_MAX_BP) return 0;

    p = &bp_entries[i];
    p->next = p_bpentries;
    p->address = mem;
    p_bpentries = p;

    p->instr = *(p->address);
    *(p->address) = BPCODE;

    DCStoreRangeNoSync((void*)((u32)mem&~0x1f),32);
    ICInvalidateRange((void*)((u32)mem&~0x1f),32);
    _sync();

    return 1;
}
예제 #12
0
파일: rdcli.c 프로젝트: kbumsik/RIOT
int rdcli_register(const sock_udp_ep_t *remote, const char *regif)
{
    assert(remote);

    int res;
    ssize_t pkt_len;
    int retval;
    coap_pkt_t pkt;

    _lock();

    /* if no registration interface is given, we will need to trigger a URI
     * discovery for it first (see section 5.2) */
    if (regif == NULL) {
        retval = _discover_internal(remote, _rd_regif, sizeof(_rd_regif));
        if (retval != RDCLI_OK) {
            goto end;
        }
    }
    else {
        if (strlen(_rd_regif) >= sizeof(_rd_regif)) {
            retval = RDCLI_OVERFLOW;
            goto end;
        }
        strncpy(_rd_regif, regif, sizeof(_rd_regif));
    }

    /* build and send CoAP POST request to the RD's registration interface */
    res = gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST, _rd_regif);
    if (res < 0) {
        retval = RDCLI_ERR;
        goto end;
    }
    /* set some packet options and write query string */
    coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
    rdcli_common_add_qstring(&pkt);

    /* add the resource description as payload */
    res = gcoap_get_resource_list(pkt.payload, pkt.payload_len,
                                  COAP_FORMAT_LINK);
    if (res < 0) {
        retval = RDCLI_ERR;
        goto end;
    }

    /* finish up the packet */
    pkt_len = gcoap_finish(&pkt, res, COAP_FORMAT_LINK);

    /* send out the request */
    res = gcoap_req_send2(buf, pkt_len, remote, _on_register);
    if (res < 0) {
        retval = RDCLI_ERR;
        goto end;
    }
    retval = _sync();

end:
    /* if we encountered any error, we mark the client as not connected */
    if (retval != RDCLI_OK) {
        _rd_loc[0] = '\0';
    }
#ifdef MODULE_RDCLI_STANDALONE
    else {
        rdcli_standalone_signal(true);
    }
#endif

    mutex_unlock(&_mutex);
    return retval;
}
예제 #13
0
void doexit(int16_t val, int16_t val2)
{
	int16_t j;
	ptptr p;
	irqflags_t irq;

#ifdef DEBUG
	kprintf("process %d exiting\n", udata.u_ptab->p_pid);

	kprintf
	    ("udata.u_page %u, udata.u_ptab %x, udata.u_ptab->p_page %u\n",
	     udata.u_page, udata.u_ptab, udata.u_ptab->p_page);
#endif
	if (udata.u_ptab->p_pid == 1)
		panic("killed init");

	_sync();		/* Not necessary, but a good idea. */

	irq = di();

	/* Discard our memory before we blow away and reuse the memory */
	pagemap_free(udata.u_ptab);

	for (j = 0; j < UFTSIZE; ++j) {
		if (udata.u_files[j] != NO_FILE)
			doclose(j);
	}


	udata.u_ptab->p_exitval = (val << 8) | (val2 & 0xff);

	i_deref(udata.u_cwd);
	i_deref(udata.u_root);

	/* Stash away child's execution tick counts in process table,
	 * overlaying some no longer necessary stuff.
	 *
	 * Pedantically POSIX says we should do this at the point of wait()
	 */
	udata.u_utime += udata.u_cutime;
	udata.u_stime += udata.u_cstime;
	memcpy(&(udata.u_ptab->p_priority), &udata.u_utime,
	       2 * sizeof(clock_t));

	for (p = ptab; p < ptab_end; ++p) {
		if (p->p_status == P_EMPTY || p == udata.u_ptab)
			continue;
		/* Set any child's parents to our parent */
		if (p->p_pptr == udata.u_ptab)
			p->p_pptr = udata.u_ptab->p_pptr;
		/* Send SIGHUP to any pgrp members and remove
		   them from our pgrp */
                if (p->p_pgrp == udata.u_ptab->p_pid) {
			p->p_pgrp = 0;
			ssig(p, SIGHUP);
		}
	}
	tty_exit();
	irqrestore(irq);
#ifdef DEBUG
	kprintf
	    ("udata.u_page %u, udata.u_ptab %x, udata.u_ptab->p_page %u\n",
	     udata.u_page, udata.u_ptab, udata.u_ptab->p_page);
#endif
#ifdef CONFIG_ACCT
	acctexit(p);
#endif
        udata.u_page = 0xFFFFU;
        udata.u_page2 = 0xFFFFU;
	/* FIXME: send SIGCLD here */
	/* FIXME: POSIX.1 says that SIG_IGN for SIGCLD means don't go
	   zombie, just clean up as we go */
	/* Wake up a waiting parent, if any. */
	wakeup((char *) udata.u_ptab->p_pptr);

	udata.u_ptab->p_status = P_ZOMBIE;
	nready--;
	nproc--;

	switchin(getproc());
	panic("doexit: won't exit");
}
예제 #14
0
neam::cr::storage::~storage()
{
  _sync();
  if (mapped_file)
    delete mapped_file;
}
예제 #15
0
파일: sync.c 프로젝트: OS2World/LIB-POSIX2
	int
sync(void) {return(_sync());}