奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

嵌入式培訓 百分網手機站

嵌入式軟件助理工程師認證考試試題題庫(5)

時間:2018-04-01 11:42:31 嵌入式培訓 我要投稿

2016年嵌入式軟件助理工程師認證考試試題題庫

  in tints[20]={

  10, 20, 30, 40, 50, 60, 70, 80, 90, 100,

  110, 120, 130, 140, 150, 160, 170, 180, 190, 200

  };

  (Other declarations)

  int *ip=ints+3;

表達式

ints

__   ____

ints[4]

__   ____

ip

__   ____

ip[4]

__   ____

*(ip+4)

__   ____

  答:(每項1分)

表達式

ints

__     100   ____

Ints[4]

    50   ____

ip

__  112 ____

ip[4]

__  80 ____

*(ip+4)

__   80____

  5、請對下列shell程序加注釋,并說明程序的功能和調用方法:

  #!/bin/sh

  #

  # /etc/rc.d/rc.httpd

  #

  # Start/stop/restart the Apache web server.

  #

  # To make Apache start automatically at boot, make this

  # file executable: chmod 755 /etc/rc.d/rc.httpd

  #

  case "$1" in

  'start')

  /usr/sbin/apachectl start ;;

  'stop')

  /usr/sbin/apachectl stop ;;

  'restart')

  /usr/sbin/apachectl restart ;;

  *)

  echo "usage $0 start|stop|restart" ;;

  esac

  答:

  1)程序注釋

  #!/bin/sh 定義實用的shell

  #

  # /etc/rc.d/rc.httpd 注釋行,凡是以星號開始的行均為注釋行。

  #

  # Start/stop/restart the Apache web server.

  #

  # To make Apache start automatically at boot, make this

  # file executable: chmod 755 /etc/rc.d/rc.httpd

  #

  case "$1" in #case結構開始,判斷“位置參數”決定執行的操作。本程序攜帶一個“位置參數”,即$1

  'start') #若位置參數為start

  /usr/sbin/apachectl start ;; #啟動httpd進程

  'stop') #若位置參數為stop

  /usr/sbin/apachectl stop ;; #關閉httpd進程

  'restart') #若位置參數為stop

  /usr/sbin/apachectl restart ;; #重新啟動httpd進程

  *) #若位置參數不是start、stop或restart時

  echo "usage $0 start|stop|restart" ;; #顯示命令提示信息:程序的調用方法

  esac #case結構結束

  (2)程序的功能是啟動,停止或重新啟動httpd進程

  (3)程序的調用方式有三種:啟動,停止和重新啟動。

  七、應用實踐題

  1、管道是Linux中進程通信的一種方式,以下程序在父進程和子進程之間創建了一個管道,然后建立它們之間的通信,實現父進程向子進程寫數據的功能。說明標號所在行代碼的功能。

  #include

  #include

  #include

  #include

  #include

  int main()

  {

  int pipe_fd[2];

  pid_t pid;

  char buf_r[100];

  char* p_wbuf;

  int r_num;

  memset(buf_r,0,sizeof(buf_r)); (1)

  if(pipe(pipe_fd)<0) (2)

  {

  printf("pipe create error\n");

  return -1;

  }

  if((pid=fork())==0) (3)

  {

  printf("\n");

  close(pipe_fd[1]); (4)

  sleep(2);

  if((r_num=read(pipe_fd[0],buf_r,100))>0) (5)

  {

  printf( "%d numbers read from the pipe is %s\n",r_num,buf_r);

  }

  close(pipe_fd[0]); (6)

  exit(0);

  }

  else if(pid>0) (7)

  {

  close(pipe_fd[0]); (8)

  if(write(pipe_fd[1],"Hello",5)!=-1) (9)

  printf("parent write1 success!\n");

  if(write(pipe_fd[1]," Pipe",5)!=-1)

  printf("parent write2 success!\n");

  close(pipe_fd[1]); (10)

  sleep(3);

  waitpid(pid,NULL,0);

  exit(0);

  }

  }

  答案要點:(1) 將數據緩沖區清0 (2) 創建管道 (3) 創建子進程 (4) 關閉子進程寫描述符 (5) 子進程讀取管道內容 (6) 關閉子進程讀描述符 (7) 父進程運行控制語句 (8) 關閉父進程的讀描述符 (9) 將數據寫入緩沖區

  (10) 關閉父進程寫描述符

  2、用Shell編程,判斷一文件是不是字符設備文件,如果是將其拷貝到 /dev 目錄下。

  答:

  #!/bin/sh

  FILENAME=

  echo “Input file name:”

  read FILENAME

  if [ -c "$FILENAME" ]

  then

  cp $FILENAME /dev

  fi

  3.下列程序實現了著名的生產者—消費者問題的模型,主程序中分別啟動了生產者線程和消費者線程。生產者不斷順序地將0-1000的數字寫入共享的循環緩沖區,同時消費者線程不斷地從共享的循環緩沖區中讀取數據。完成如下問題。

  進行生產(put) 進行消費(get)

  1)生產者 寫入共享的循環緩沖區PUT函數的流程圖如下,試完成流程圖中標號所在處的內容。(4.5分)

  (1)寫指針+1是否等于讀指針 (2)等待條件變量not full (3) 設置條件變量notempty

  2)生產者 寫入共享的循環緩沖區PUT函數的流程圖如下,試完成流程圖中標號所在處的內容。(4.5分)

  (4)寫指針是否等于讀指針 (5) 等待條件變量not empty (6) 設置條件變量notfull

  void put(struct prodcons * b, int data)

  { pthread_mutex_lock(&b->lock);

  while ((b->writepos + 1) % BUFFER_SIZE == b->readpos) {

  printf("wait for not full\n");

  pthread_cond_wait(&b->notfull, &b->lock);

  }

  b->buffer[b->writepos] = data;

  b->writepos++;

  if (b->writepos >= BUFFER_SIZE) b->writepos = 0;

  pthread_cond_signal(&b->notempty);

  pthread_mutex_unlock(&b->lock);

  }

  int get(struct prodcons * b)

  {

  int data;

  pthread_mutex_lock(&b->lock);

  while (b->writepos == b->readpos) {

  printf("wait for not empty\n");

  pthread_cond_wait(&b->notempty, &b->lock);

  }

  data = b->buffer[b->readpos];

  b->readpos++;

  if (b->readpos >= BUFFER_SIZE) b->readpos = 0;

  pthread_cond_signal(&b->notfull);

  pthread_mutex_unlock(&b->lock);

  return data;

  }

  void * producer(void * data)

  { int n;

  for (n = 0; n < 1000; n++) {

  printf(" put-->%d\n", n);

  put(&buffer, n);

  }

  put(&buffer, OVER);

  printf("producer stopped!\n");

  return NULL;

  }

  void * consumer(void * data)

  { int d;

  while (1) {

  d = get(&buffer);

  if (d == OVER ) break;

  printf(" %d-->get\n", d);

  }

  printf("consumer stopped!\n");

  return NULL;

  }

  int main(void)

  { pthread_t th_a, th_b;

  void * retval;

  init(&buffer);

  pthread_create(&th_a, NULL, producer, 0);

  pthread_create(&th_b, NULL, consumer, 0);

  pthread_join(th_a, &retval);

  pthread_join(th_b, &retval);

  return 0;

  }

  4、設計一個Shell程序,在/userdata目錄下建立50個目錄,即user1~user50,并設置每個目錄的權限,其中其他用戶的權限為:讀;文件所有者的權限為:讀、寫、執行;文件所有者所在組的權限為:讀、執行。

  答:

  #!/bin/sh

  i=1

  while [ i -le 50 ]

  do

  if [ -d /userdata ];then

  mkdir -p /userdata/user$i

  chmod 754 /userdata/user$i

  echo "user$i"

  let "i = i + 1" (或i=$(($i+1))

  else

  mkdir /userdata

  mkdir -p /userdata/user$i

  chmod 754 /userdata/user$i

  echo "user$i"

  let "i = i + 1" (或i=$(($i+1))

  fi

  done

  5、用變量a給出下面的定義

  f) 一個指向整型數的指針(A pointer to an integer)

  g) 一個指向指針的的指針,它指向的指針是指向一個整型數(A pointer to a pointer to an integer)

  h) 一個有10個整型數的數組(An array of 10 integers)

  i) 一個有10個指針的數組,該指針是指向一個整型數的(An array of 10 pointers to integers)

  j) 一個指向有10個整型數數組的指針(A pointer to an array of 10 integers)

  2、答:

  a) int *a; // A pointer to an integer

  b) int **a; // A pointer to a pointer to an integer

  c) int a[10]; // An array of 10 integers

  d) int *a[10]; // An array of 10 pointers to integers

  e) int (*a)[10]; // A pointer to an array of 10 integers

  6.根據下面給出的聲明和數據,對每個表達式進行求值并寫出他的值。在每個表達式進行求值是使用原來給出的值(也就是說,某個表達式的結果不影響后面的表達式)。假定ints數組在內存中的起始位置是100,整型值和指針的長度都是4字節。

  in tints[20]={

  10, 20, 30, 40, 50, 60, 70, 80, 90, 100,

  110, 120, 130, 140, 150, 160, 170, 180, 190, 200

  };

  (Other declarations)

  int *ip=ints+3;

表達式

ints

__   ____

ints[4]

__   ____

ip

__   ____

ip[4]

__   ____

*(ip+4)

__   ____

  答:(每項1分)

表達式

ints

__     100   ____

Ints[4]

    50   ____

ip

__  112 ____

ip[4]

__  80 ____

*(ip+4)

__   80____

  7、由于Boot Loader的實現依賴于 CPU 的體系結構,因此大多數Boot Loader都分為 stage1 和 stage2 兩大部分。依賴于 CPU 體系結構的代碼,比如設備初始化代碼等,通常都放在 stage1 中,而且通常都用匯編語言來實現,以達到短小精悍的目的。而stage2 則通常用C語言來實現,這樣可以實現給復雜的功能,而且代碼會具有更好的可讀性和可移植性。請根據你對嵌入式系統中bootloader的理解,簡要設計一下stage1和stage2需要完成的功能。

  參考答案:

  BootLoader 的 stage1 通常包括以下步驟(以執行的先后順序):(3分)

  基本硬件設備初始化。

  為加載 Boot Loader 的 stage2 準備 RAM 空間。

  拷貝 Boot Loader 的 stage2 到 RAM 空間中。

  設置好堆棧。

  跳轉到 stage2 的C入口點。

  BootLoader 的 stage2 通常包括以下步驟(以執行的先后順序): (3分)

  初始化本階段要使用到的硬件設備。

  檢測系統內存映射(memory map)。

  將 kernel 映像和根文件系統映像從 flash 上讀到 RAM 空間中。

  為內核設置啟動參數。

  調用內核。

  8、Qt/Embedded對嵌入式GUI提供了強大的支持,信號和插槽機制是QT的核心機制,使用QT實現如下界面的登陸程序,其原代碼如下所示,請回答如下問題:

  1)什么是Qt中的信號插槽機制?(3分)

  2)應用程序中用到了哪些控件,列舉2個并說明該控件的特點?(4分)

  3)根據注釋完成程序中相應的語句?(4分)

  #include

  #include "window.h"

  CWinDlg::CWinDlg(QWidget* parent) : QDialog(parent)

  {

  setWindowTitle("Example");

  Edit1 = new QLineEdit;

  Button1 = new QPushButton("OK");

  Edit1->setEchoMode(QLineEdit::Password);

  QVBoxLayout* Layout1 = new QVBoxLayout;

  Layout1->addWidget(Edit1);

  Layout1->addWidget(Button1);

  (1) ;

  (2) ;

  }

  CWinDlg::~CWinDlg()

  {

  delete Edit1;

  delete Button1;

  }

  void CWinDlg::function()

主站蜘蛛池模板: 百色市| 泽州县| 西林县| 余姚市| 石景山区| 长白| 花莲市| 裕民县| 威远县| 雷州市| 长寿区| 丰台区| 漯河市| 图木舒克市| 汝城县| 同德县| 柳林县| 肥东县| 普兰县| 望江县| 衡阳县| 静宁县| 时尚| 卓资县| 内黄县| 遂宁市| 麻栗坡县| 汉沽区| 和田县| 石泉县| 兴国县| 东阿县| 西充县| 绥宁县| 凤台县| 竹山县| 咸宁市| 汝城县| 建德市| 哈尔滨市| 浮梁县|