void *begintx(void *arg){ //Initialize a transaction object. Make sure it is //done after acquiring the semaphore for the tm and making sure that //the operation can proceed using the condition variable. when creating //the tx object, set the tx to TR_ACTIVE and obno to -1; there is no //semno as yet as none is waiting on this tx. struct param *node = (struct param*)arg;// get tid and count start_operation(node->tid, node->count); printf("begin is here"); zgt_tx *tx = new zgt_tx(node->tid,TR_ACTIVE, node->Txtype, pthread_self()); // Create new tx node open_logfile_for_append(); fprintf(logfile, "T%d\t%c \tBeginTx\n", node->tid, node->Txtype); // Write log record and close fflush(logfile); zgt_p(0); // Lock Tx manager; Add node to transaction list tx->nextr = ZGT_Sh->lastr; ZGT_Sh->lastr = tx; zgt_v(0); // Release tx manager finish_operation(node->tid); pthread_exit(NULL); // thread exit }
void gconf_defaults_unset_mandatory (GConfDefaults *mechanism, const char **includes, const char **excludes, DBusGMethodInvocation *context) { UnsetData *udata; ActionData *adata; start_operation (); udata = g_new0 (UnsetData, 1); udata->mechanism = g_object_ref (mechanism); udata->context = context; udata->includes = g_strdupv ((gchar **)includes); udata->excludes = g_strdupv ((gchar **)excludes); adata = g_new0 (ActionData, 1); adata->mechanism = g_object_ref (mechanism); adata->context = context; adata->includes = g_strdupv ((gchar **)includes); adata->auth_obtained_callback = do_unset_authorized; adata->data = udata; adata->destroy = unset_data_free; adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix"; adata->default_action = "org.gnome.gconf.defaults.set-mandatory"; polkit_authority_enumerate_actions (mechanism->priv->auth, NULL, actions_ready_cb, adata); }
void *writetx(void *arg){ //do the operations for writing; similar to readTx struct param *node = (struct param*)arg; // struct parameter that contains start_operation(node->tid, node->count); //do the operations for writing; similar to readTx. Write your code zgt_p(0); // Lock Tx manager; zgt_tx *txptr=get_tx(node->tid); if(txptr != NULL){ txptr->print_tm(); if(txptr->status == TR_ABORT){//tx is aborted fprintf(logfile, "T%d\t%c \tWriteTx\n", node->tid, node->Txtype); // Write log record and close fflush(logfile); zgt_v(0); // Release tx manager } else if(txptr->status == TR_ACTIVE){//Tx is active zgt_v(0); // Release tx manager int isLockObtain=txptr->set_lock(node->tid, txptr->sgno,node->obno, node->count,'X');//check is lock available if(isLockObtain == 0){//Lock is obtain for tx txptr->perform_readWrite(txptr->tid,node->obno,'X'); } } } else { zgt_v(0); // Release tx manager printf("Tx is not found it might be committed or not begin at all"); } finish_operation(node->tid); pthread_exit(NULL); // thread exit }
static void do_check (GConfDefaults *mechanism, gboolean mandatory, const gchar **includes, DBusGMethodInvocation *context) { ActionData *adata; start_operation (); adata = g_new0 (ActionData, 1); adata->mechanism = g_object_ref (mechanism); adata->context = context; adata->includes = g_strdupv ((gchar **)includes); adata->actions_ready_callback = check_permissions_only; adata->auth_obtained_callback = NULL; adata->data = NULL; adata->destroy = NULL; if (mandatory) { adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix"; adata->default_action = "org.gnome.gconf.defaults.set-mandatory"; } else { adata->annotation_key = "org.gnome.gconf.defaults.set-system.prefix"; adata->default_action = "org.gnome.gconf.defaults.set-system"; } polkit_authority_enumerate_actions (mechanism->priv->auth, NULL, actions_ready_cb, adata); }
uint8_t SHA204I2C::send(uint8_t word_address, uint8_t count, uint8_t *buffer) { if (DEBUG()>=DEBUG_INFO) {Serial.println(F("* DEBUG * send()")); Serial.flush();} uint8_t i2c_status; Wire.beginTransmission(deviceAddress()); start_operation(I2C_WRITE); i2c_status = send_bytes(1, &word_address); if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * i2c_status{1} = "));Serial.println(i2c_status,HEX);Serial.flush();} if (i2c_status != I2C_FUNCTION_RETCODE_SUCCESS) { if (DEBUG()>=DEBUG_WARN) {Serial.print(F("* DEBUG * send() fail 1, i2c_status{1} = "));Serial.println(i2c_status,HEX);Serial.flush();} return SHA204_COMM_FAIL; } if (count == 0) { return SHA204_SUCCESS; } i2c_status = send_bytes(count, buffer); if (DEBUG()>=DEBUG_TRACE) {Serial.print(F("* DEBUG * i2c_status{2} = "));Serial.println(i2c_status,HEX);Serial.flush();} if (i2c_status != I2C_FUNCTION_RETCODE_SUCCESS) { if (DEBUG()>=DEBUG_WARN) {Serial.print(F("* DEBUG * send() fail 2, i2c_status{2} = "));Serial.println(i2c_status,HEX);Serial.flush();} return SHA204_COMM_FAIL; } Wire.endTransmission(); return SHA204_SUCCESS; }
int SRLockClient::start_client () { SRClientContext ctx; char temp_char; ctx.ib_port = SERVER_IB_PORT; srand (generate_random_seed()); // initialize random seed TEST_NZ (establish_tcp_connection(SERVER_ADDR.c_str(), SERVER_TCP_PORT, &(ctx.sockfd))); DEBUG_COUT("[Comm] Client connected to LM on sock " << ctx.sockfd); TEST_NZ (ctx.create_context()); DEBUG_COUT("[Info] Context Created " << ctx.sockfd); TEST_NZ (RDMACommon::connect_qp (&(ctx.qp), ctx.ib_port, ctx.port_attr.lid, ctx.sockfd)); DEBUG_COUT("[Conn] QP connected!"); start_operation(ctx); // Sync so server will know that client is done mucking with its memory DEBUG_COUT("[Info] Client is done, and is ready to destroy its resources!"); TEST_NZ (sock_sync_data (ctx.sockfd, 1, "W", &temp_char)); /* just send a dummy char back and forth */ TEST_NZ(ctx.destroy_context()); }
void on_format_button_clicked(GtkWidget* w, gpointer user_data) { FormatDialog* dialog = g_object_get_data( G_OBJECT(gtk_widget_get_toplevel(w)), "userdata" ); FormatVolume* vol; gchar* fs = NULL; gboolean do_encrypt = FALSE; /* Figure out the device params */ GtkTreeIter iter; if(!gtk_combo_box_get_active_iter(dialog->volume_combo, &iter)) return; if( !(vol = get_cached_device_from_treeiter(dialog, &iter)) ) return; fs = get_fs_from_menu(dialog); if(!fs) goto error_out; if(!warn_user_of_impending_doom(dialog, vol)) { g_debug("User cancelled format!"); goto error_out; } /* TODO: Here's where we'll add the floppy support */ gboolean create_table = !(vol->volume || libhal_drive_no_partitions_hint(vol->drive)); start_operation(dialog, 2 + (create_table ? 1 : 0) + (do_encrypt ? 1 : 0)); if(create_table) { do_next_operation(dialog, _("Creating partition table...")); /* TODO: Figure out what to do if any other partition is mounted on this drive */ if(!(vol = write_partition_table(dialog, vol, fs))) goto error_out; if(!vol->volume) goto error_out; } if(do_encrypt) { /* TODO: Set up encryption here */ } g_debug("Creating filesystem on %s...\n", vol->friendly_name); do_next_operation(dialog, _("Creating filesystem...")); do_mkfs(dialog, libhal_volume_get_device_file(vol->volume)); do_next_operation(dialog, _("Syncing changes...")); g_spawn_command_line_sync("sync", NULL, NULL, NULL, NULL); error_out: if(fs) g_free(fs); return; }
void *aborttx(void *arg) { struct param *node = (struct param*)arg;// get tid and count start_operation(node->tid, node->count); zgt_p(0); //locking the transaction manager do_commit_abort(node->tid,TR_ABORT); zgt_v(0); // releasing the transaction manager finish_operation(node->tid); pthread_exit(NULL); // thread exit }
static void do_copy (GConfDefaults *mechanism, gboolean mandatory, const gchar **includes, const gchar **excludes, GConfValue *value, DBusGMethodInvocation *context, ChangeSetCallback changeset_callback, gpointer user_data, GDestroyNotify destroy) { CopyData *cdata; ActionData *adata; start_operation (); cdata = g_new0 (CopyData, 1); cdata->mechanism = g_object_ref (mechanism); cdata->context = context; cdata->includes = g_strdupv ((gchar **)includes); cdata->excludes = g_strdupv ((gchar **)excludes); cdata->value = value; cdata->actions = NULL; cdata->changeset_callback = changeset_callback; cdata->user_data = user_data; cdata->destroy = destroy; adata = g_new0 (ActionData, 1); adata->mechanism = g_object_ref (mechanism); adata->context = context; adata->includes = g_strdupv ((gchar **)includes); adata->actions_ready_callback = check_polkit_for_actions; adata->auth_obtained_callback = do_copy_authorized; adata->data = cdata; adata->destroy = copy_data_free; /* check privileges for each include */ if (mandatory) { adata->annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix"; adata->default_action = "org.gnome.gconf.defaults.set-mandatory"; cdata->dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.mandatory"; } else { adata->annotation_key = "org.gnome.gconf.defaults.set-system.prefix"; adata->default_action = "org.gnome.gconf.defaults.set-system"; cdata->dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.system"; } polkit_authority_enumerate_actions (mechanism->priv->auth, NULL, actions_ready_cb, adata); }
void *committx(void *arg) { //remove the locks before committing struct param *node = (struct param*)arg;// get tid and count start_operation(node->tid, node->count); zgt_tx *txptr=get_tx(node->tid); zgt_p(0); // locking the transaction manager txptr->status=TR_END; do_commit_abort(node->tid,TR_END); zgt_v(0); // releasing the transaction manager finish_operation(node->tid); pthread_exit(NULL); // thread exit }