说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

Android开发进阶之NIO非阻塞包(八)

HTML文档下载 WORD文档下载 PDF文档下载
Android开发进阶之NIO非阻塞包(八)

作者:Android开发网


   在整个DDMS中体现Android NIO主要框架的要数MonitorThread.java这个文件了,有关PC和Android手机同步以及NIO非阻塞编程的精髓可以在下面的文件中充分体现出来。

  final class MonitorThread extends Thread {

    private static final int CLIENT_READY = 2;

    private static final int CLIENT_DISCONNECTED = 3;

    private volatile boolean mQuit = false;

    private ArrayList<Client> mClientList; //用一个数组保存客户端信息

    private Selector mSelector;

    private HashMap<Integer, ChunkHandler> mHandlerMap; //这里Android123提示大家,由于在多线程中concurrentHashMap效率比HashMap更安全高效,推荐使用并发库的这个替代版本。

    private ServerSocketChannel mDebugSelectedChan; //一个用于调试的服务器通道

    private int mNewDebugSelectedPort;

    private int mDebugSelectedPort = -1;

    private Client mSelectedClient = null;

    private static MonitorThread mInstance;

    private MonitorThread() {
        super("Monitor");
        mClientList = new ArrayList<Client>();
        mHandlerMap = new HashMap<Integer, ChunkHandler>();

        mNewDebugSelectedPort = DdmPreferences.getSelectedDebugPort();
    }

    static MonitorThread createInstance() {  //创建实例
        return mInstance = new MonitorThread();
    }

    static MonitorThread getInstance() { //获取实例
        return mInstance;
    }

    synchronized void setDebugSelectedPort(int port) throws IllegalStateException { //设置调试端口号
        if (mInstance == null) {
            return;
        }

        if (AndroidDebugBridge.getClientSupport() == false) {
            return;
        }

        if (mDebugSelectedChan != null) {
            Log.d("ddms", "Changing debug-selected port to " + port);
            mNewDebugSelectedPort = port;
            wakeup(); //这里用来唤醒所有的Selector
        } else {
            // we set mNewDebugSelectedPort instead of mDebugSelectedPort so that it's automatically
            mNewDebugSelectedPort = port;
        }
    }

    synchronized void setSelectedClient(Client selectedClient) {
        if (mInstance == null) {
            return;
        }

        if (mSelectedClient != selectedClient) {
            Client oldClient = mSelectedClient;
            mSelectedClient = selectedClient;

            if (oldClient != null) {
                oldClient.update(Client.CHANGE_PORT);
            }

            if (mSelectedClient != null) {
                mSelectedClient.update(Client.CHANGE_PORT);
            }
        }
    }

    Client getSelectedClient() {
        return mSelectedClient;
    }

    boolean getRetryOnBadHandshake() {
        return true; // TODO? make configurable
    }

    Client[] getClients() {
        synchronized (mClientList) {
            return mClientList.toArray(new Client[0]);
        }
    }

    synchronized void registerChunkHandler(int type, ChunkHandler handler) {
        if (mInstance == null) {
            return;
        }

        synchronized (mHandlerMap) {
            if (mHandlerMap.get(type) == null) {
                mHandlerMap.put(type, handler);
            }
        }
    }

    @Override
    public void run() { //本类的主要线程
        Log.d("ddms", "Monitor is up");

        try {
            mSelector = Selector.open();
        } catch (IOException ioe) {
            Log.logAndDisplay(LogLevel.ERROR, "ddms",
                    "Failed to initialize Monitor Thread: " + ioe.getMessage());
            return;
        }

        while (!mQuit) {

            try {
                synchronized (mClientList) {
                }

                try {
                    if (AndroidDebugBridge.getClientSupport()) {
                        if ((mDebugSelectedChan == null ||
                                mNewDebugSelectedPort != mDebugSelectedPort) &&
                                mNewDebugSelectedPort != -1) {
                            if (reopenDebugSelectedPort()) {
                                mDebugSelectedPort = mNewDebugSelectedPort;
                            }
                        }
                    }
                } catch (IOException ioe) {
                    Log.e("ddms",
                            "Failed to reopen debug port for Selected Client to: " + mNewDebugSelectedPort);
                    Log.e("ddms", ioe);
                    mNewDebugSelectedPort = mDebugSelectedPort; // no retry
                }

                int count;
                try {
                    count = mSelector.select();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                    continue;
                } catch (CancelledKeyException cke) {
                    continue;
                }

                if (count == 0) {
                    continue;
                } //这里代码写的不是很好,Android开发网提示大家因为这个NIO是DDMS工作在PC端的还不明显,这样轮训的在一个while中,效率不是很高,CPU很容易占用率很高。

                Set<SelectionKey> keys = mSelector.selectedKeys();
                Iterator<SelectionKey> iter = keys.iterator(); //使用迭代器获取这个选择键

                while (iter.hasNext()) {
                    SelectionKey key = iter.next();
                    iter.remove();

                    try {
                        if (key.attachment() instanceof Client) { //判断收到的key的附件是否是Client的实例
                            processClientActivity(key);
                        }
                        else if (key.attachment() instanceof Debugger) { //如果是Debug实例
                            processDebuggerActivity(key);
                        }
                        else if (key.attachment() instanceof MonitorThread) {
                            processDebugSelectedActivity(key);
                        }
                        else {
                            Log.e("ddms", "unknown activity key");
                        }
                    } catch (Exception e) {
                        Log.e("ddms", "Exception during activity from Selector.");
                        Log.e("ddms", e);
                    }
                }
            } catch (Exception e) {
                Log.e("ddms", "Exception MonitorThread.run()");
                Log.e("ddms", e);
            }
        }
    }

    int getDebugSelectedPort() {
        return mDebugSelectedPort;
    }

    private void processClientActivity(SelectionKey key) {
        Client client = (Client)key.attachment();

        try {
            if (key.isReadable() == false || key.isValid() == false) {
                Log.d("ddms", "Invalid key from " + client + ". Dropping client.");
                dropClient(client, true /* notify */);
                return;
            }

            client.read();

            JdwpPacket packet = client.getJdwpPacket();
            while (packet != null) {
                if (packet.isDdmPacket()) {
                    // unsolicited DDM request - hand it off
                    assert !packet.isReply();
                    callHandler(client, packet, null);
                    packet.consume();
                } else if (packet.isReply()
                        && client.isResponseToUs(packet.getId()) != null) {
                    // reply to earlier DDM request
                    ChunkHandler handler = client
                            .isResponseToUs(packet.getId());
                    if (packet.isError())
                        client.packetFailed(packet);
                    else if (packet.isEmpty())
                        Log.d("ddms", "Got empty reply for 0x"
                                + Integer.toHexString(packet.getId())
                                + " from " + client);
                    else
                        callHandler(client, packet, handler);
                    packet.consume();
                    client.removeRequestId(packet.getId());
                } else {
                    Log.v("ddms", "Forwarding client "
                            + (packet.isReply() ? "reply" : "event") + " 0x"
                            + Integer.toHexString(packet.getId()) + " to "
                            + client.getDebugger());
                    client.forwardPacketToDebugger(packet);
                }

                packet = client.getJdwpPacket();
            }
        } catch (CancelledKeyException e) { //注意正确处理这个异常
            dropClient(client, true /* notify */);
        } catch (IOException ex) {
            dropClient(client, true /* notify */);
        } catch (Exception ex) {
            Log.e("ddms", ex);

            dropClient(client, true /* notify */);

            if (ex instanceof BufferOverflowException) { //可能存在缓冲区异常
                Log.w("ddms",
                        "Client data packet exceeded maximum buffer size "
                                + client);
            } else {
                // don't know what this is, display it
                Log.e("ddms", ex);
            }
        }
    }

    private void callHandler(Client client, JdwpPacket packet,
            ChunkHandler handler) {

        // on first DDM packet received, broadcast a "ready" message
        if (!client.ddmSeen())
            broadcast(CLIENT_READY, client);

        ByteBuffer buf = packet.getPayload();
        int type, length;
        boolean reply = true;

        type = buf.getInt();
        length = buf.getInt();

        if (handler == null) {
            // not a reply, figure out who wants it
            synchronized (mHandlerMap) {
                handler = mHandlerMap.get(type);
                reply = false;
            }
        }

        if (handler == null) {
            Log.w("ddms", "Received unsupported chunk type "
                    + ChunkHandler.name(type) + " (len=" + length + ")");
        } else {
            Log.d("ddms", "Calling handler for " + ChunkHandler.name(type)
                    + " [" + handler + "] (len=" + length + ")");
            ByteBuffer ibuf = buf.slice();
            ByteBuffer roBuf = ibuf.asReadOnlyBuffer(); // enforce R/O
            roBuf.order(ChunkHandler.CHUNK_ORDER);
            synchronized (mClientList) {
                handler.handleChunk(client, type, roBuf, reply, packet.getId());
            }
        }
    }

    synchronized void dropClient(Client client, boolean notify) {
        if (mInstance == null) {
            return;
        }

        synchronized (mClientList) {
            if (mClientList.remove(client) == false) {
                return;
            }
        }
        client.close(notify);
        broadcast(CLIENT_DISCONNECTED, client);

        /*
         * http://forum.java.sun.com/thread.jspa?threadID=726715&start=0
         * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5073504
         */
        wakeup();
    }

    /*
     * Process activity from one of the debugger sockets. This could be a new
     * connection or a data packet.
     */
    private void processDebuggerActivity(SelectionKey key) {
        Debugger dbg = (Debugger)key.attachment();

        try {
            if (key.isAcceptable()) { //处理Server响应这个事件
                try {
                    acceptNewDebugger(dbg, null);
                } catch (IOException ioe) {
                    Log.w("ddms", "debugger accept() failed");
                    ioe.printStackTrace();
                }
            } else if (key.isReadable()) { //如果是收到的数据,则可读取
                processDebuggerData(key);
            } else {
                Log.d("ddm-debugger", "key in unknown state");
            }
        } catch (CancelledKeyException cke) { //记住,NIO处理这个异常,很多入门的开发者很容易忘记
            // key has been cancelled we can ignore that.
        }
    }

     private void acceptNewDebugger(Debugger dbg, ServerSocketChannel acceptChan) //这里用到了阻塞方式
            throws IOException {

        synchronized (mClientList) {
            SocketChannel chan;

            if (acceptChan == null)
                chan = dbg.accept();
            else
                chan = dbg.accept(acceptChan);

            if (chan != null) {
                chan.socket().setTcpNoDelay(true);

                wakeup();

                try {
                    chan.register(mSelector, SelectionKey.OP_READ, dbg);
                } catch (IOException ioe) {
                    // failed, drop the connection
                    dbg.closeData();
                    throw ioe;
                } catch (RuntimeException re) {
                    // failed, drop the connection
                    dbg.closeData();
                    throw re;
                }
            } else {
                Log.w("ddms", "ignoring duplicate debugger");
            }
        }
    }

    private void processDebuggerData(SelectionKey key) {
        Debugger dbg = (Debugger)key.attachment();

        try {
            dbg.read();

            JdwpPacket packet = dbg.getJdwpPacket();
            while (packet != null) {
                Log.v("ddms", "Forwarding dbg req 0x"
                        + Integer.toHexString(packet.getId()) + " to "
                        + dbg.getClient());

                dbg.forwardPacketToClient(packet);

                packet = dbg.getJdwpPacket();
            }
        } catch (IOException ioe) {
            Log.d("ddms", "Closing connection to debugger " + dbg);
            dbg.closeData();
            Client client = dbg.getClient();
            if (client.isDdmAware()) {
                   Log.d("ddms", " (recycling client connection as well)");

                    client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
                        IDebugPortProvider.NO_STATIC_PORT);
            } else {
                Log.d("ddms", " (recycling client connection as well)");
                // we should drop the client, but also attempt to reopen it.
                // This is done by the DeviceMonitor.
                client.getDeviceImpl().getMonitor().addClientToDropAndReopen(client,
                        IDebugPortProvider.NO_STATIC_PORT);
            }
        }
    }

    private void wakeup() {
        mSelector.wakeup();
    }

    synchronized void quit() {
        mQuit = true;
        wakeup();
        Log.d("ddms", "Waiting for Monitor thread");
        try {
            this.join();
            // since we're quitting, lets drop all the client and disconnect
            // the DebugSelectedPort
            synchronized (mClientList) {
                for (Client c : mClientList) {
                    c.close(false /* notify */);
                    broadcast(CLIENT_DISCONNECTED, c);
                }
                mClientList.clear();
            }

            if (mDebugSelectedChan != null) {
                mDebugSelectedChan.close();
                mDebugSelectedChan.socket().close();
                mDebugSelectedChan = null;
            }
            mSelector.close();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        mInstance = null;
    }

    synchronized void addClient(Client client) {
        if (mInstance == null) {
            return;
        }

        Log.d("ddms", "Adding new client " + client);

        synchronized (mClientList) {
            mClientList.add(client);

            try {
                wakeup();

                client.register(mSelector);

                Debugger dbg = client.getDebugger();
                if (dbg != null) {
                    dbg.registerListener(mSelector);
                }
            } catch (IOException ioe) {
                // not really expecting this to happen
                ioe.printStackTrace();
            }
        }
    }

    /*
     * Broadcast an event to all message handlers.
     */
    private void broadcast(int event, Client client) {
        Log.d("ddms", "broadcast " + event + ": " + client);

        /*
         * The handler objects appear once in mHandlerMap for each message they
         * handle. We want to notify them once each, so we convert the HashMap
         * to a HashSet before we iterate.
         */
        HashSet<ChunkHandler> set;
        synchronized (mHandlerMap) {
            Collection<ChunkHandler> values = mHandlerMap.values();
            set = new HashSet<ChunkHandler>(values);
        }

        Iterator<ChunkHandler> iter = set.iterator();
        while (iter.hasNext()) {
            ChunkHandler handler = iter.next();
            switch (event) {
                case CLIENT_READY:
                    try {
                        handler.clientReady(client);
                    } catch (IOException ioe) {
                        // Something failed with the client. It should
                        // fall out of the list the next time we try to
                        // do something with it, so we discard the
                        // exception here and assume cleanup will happen
                        // later. May need to propagate farther. The
                        // trouble is that not all values for "event" may
                        // actually throw an exception.
                        Log.w("ddms",
                                "Got exception while broadcasting 'ready'");
                        return;
                    }
                    break;
                case CLIENT_DISCONNECTED:
                    handler.clientDisconnected(client);
                    break;
                default:
                    throw new UnsupportedOperationException();
            }
        }

    }

    /**
     * Opens (or reopens) the "debug selected" port and listen for connections.
     * @return true if the port was opened successfully.
     * @throws IOException
     */
    private boolean reopenDebugSelectedPort() throws IOException {

        Log.d("ddms", "reopen debug-selected port: " + mNewDebugSelectedPort);
        if (mDebugSelectedChan != null) {
            mDebugSelectedChan.close();
        }

        mDebugSelectedChan = ServerSocketChannel.open();
        mDebugSelectedChan.configureBlocking(false); // required for Selector

        InetSocketAddress addr = new InetSocketAddress(
                InetAddress.getByName("localhost"), //$NON-NLS-1$
                mNewDebugSelectedPort);
        mDebugSelectedChan.socket().setReuseAddress(true); // enable SO_REUSEADDR

        try {
            mDebugSelectedChan.socket().bind(addr);
            if (mSelectedClient != null) {
                mSelectedClient.update(Client.CHANGE_PORT);
            }

            mDebugSelectedChan.register(mSelector, SelectionKey.OP_ACCEPT, this);

            return true;
        } catch (java.net.BindException e) {
            displayDebugSelectedBindError(mNewDebugSelectedPort);

            // do not attempt to reopen it.
            mDebugSelectedChan = null;
            mNewDebugSelectedPort = -1;

            return false;
        }
    }

    /*
     * We have some activity on the "debug selected" port. Handle it.
     */
    private void processDebugSelectedActivity(SelectionKey key) {
        assert key.isAcceptable();

        ServerSocketChannel acceptChan = (ServerSocketChannel)key.channel();

        /*
         * Find the debugger associated with the currently-selected client.
         */
        if (mSelectedClient != null) {
            Debugger dbg = mSelectedClient.getDebugger();

            if (dbg != null) {
                Log.d("ddms", "Accepting connection on 'debug selected' port");
                try {
                    acceptNewDebugger(dbg, acceptChan);
                } catch (IOException ioe) {
                    // client should be gone, keep going
                }

                return;
            }
        }

        Log.w("ddms",
                "Connection on 'debug selected' port, but none selected");
        try {
            SocketChannel chan = acceptChan.accept();
            chan.close();
        } catch (IOException ioe) {
            // not expected; client should be gone, keep going
        } catch (NotYetBoundException e) {
            displayDebugSelectedBindError(mDebugSelectedPort);
        }
    }

    private void displayDebugSelectedBindError(int port) {
        String message = String.format(
                "Could not open Selected VM debug port (%1$d). Make sure you do not have another instance of DDMS or of the eclipse plugin running. If it's being used by something else, choose a new port number in the preferences.",
                port);

        Log.logAndDisplay(LogLevel.ERROR, "ddms", message);
    }
}

  从上面来看Android的开源代码有关PC上的写的不是很好,很多实现的地方都是用了严重的缝缝补补方式解决,有些习惯不是很到位,有关本NIO例子由于涉及的项目对象多,理解需要网友深入分析DDMS源码中的每个对象。细节写的不是很理想,Android123推荐大家,画出UML后再分析更清晰。

浅谈用VB6.0编写BO程序 巧用Visual Basic的TIMER控件 VB取得控件绝对Top值 VB如何解决VB中的Grid 控件的打印问题 VB如果自定义 MsgBox 的按钮,标题等 VB如何创建数据绑定控件。 VB如何解决VB中的Grid控件的打印问题 VB如何强制文件对话框再次读取正确的磁盘? VB如何取得RichTextBox控件中光标所在行的值? VB如何设定 MsgBox 在若干时间之后若无回应則自动关闭? VB如何使用VB控件Commom Dialog VB如何用VB6写COM组件(二) VB如何用VB6写COM组件(一) VB如何在VB中使用Delphi的控件 VB如何在运行时动态增加控件 显示和隐藏鼠标-VB资料 VB用ActiveX Control Pad VB用API函数改进ListView 控件的显示效果 用VB6.0中文版进行DHTML程序开发 用VB编写标准CGI程序 用VB编写留言板 用VB播放FLASH动画 用VB开发进程管理软件 VB用WinSock设计Chat程序 运用MSChart,生成统计图形-VB资料 向文本框等等控件的系统右键菜单里追加自己定义的菜单-VB资料 在VB中用定时控件实现长定时操作 在Visual Basic中,在GotFocus事件中快速选定文本 在程序中注册和注销 OCX 控件 -VB资料 在运行时维护DBGRID的栏位宽度-VB资料 VB怎样使用VB开发基于Sybase的C/S软件 高薪寻找西安的兼职UNIX程序 员 在delphi中,怎么调用api函数? www.alldas.de为什么无法访问了??? 如何检测被覆盖的窗口区域是否发生了变化? 高薪寻找西安的兼职UNIX 程序员 如何制作下拉菜单 请高手指点:好猫为何不工作? 一种设想,20台电脑5根电话线上网,如何达到较快的速度? 对话框程序调试时的问题?!!!! 请介绍几本好用的自学C语言的书籍好吗?? 紧急求救,请高手来看看 .NET和JAVA到底哪个好? 谁来救我?ISequentialStream::write()为何不好使? 定义类型的困惑 大虾们,如何做一个图标选择框!!!(详情见内) ADO编程问题求解!!!!!!!!!!! ****************简单问题,高分求救??????????????????????? 请问怎样在TabStrip中的选项卡中增加图片?谢了 工程如何能建的工整一些? www.alldas.de为什么无法访问了? 关于动态控件的问题 ADO编程问题求解 怎么编程产生1MHz甚至更高频率的周期信号? 紧急求助—有关JMail4.1附件问题 挥泪大送分!!!!! 怎样才能让自己变胖? 做个仅有对话框的应用,但想把它放到托盘, 给ASP爱好者提个建议! 关于SQLserver2000“视图“的两个问题,请教高手! 好久没上网了,送分以庆祝再回csdn!!!!! 做浏览器,如何实现 “后退”,“前进”,这二个功能? 如何使C:盘,D盘的根目录不共享? 用resin时,是否需要jdk,如何配置?分必给! SDI中的某一个子视图里怎样对主窗口的状态栏进行更改?? ◇◆◇ 失恋代表什么? ◇◆◇ 我英语不懂,想考高程.行吗 ◇◆◇ 学生生涯快完了,大家来说说对学生生涯的感受,特别是什么最深刻的! ◇◆◇ 求救!如何把SQL命令从前端应用程序传给应用程序服务器 要去招商行笔试了,有参加过的兄弟给点建议。 ###############讨论一下->微软全力推出.NET技术和C#语言的出现,VC++还有多久的寿命??? 要去招商行笔试了,有参加过的兄弟给点建议 如何发一消息,帮别人问的 高手帮助!!! 要去招商行笔试,有参加过的兄弟给点建议。 要去招商行笔试,有参加过的兄弟给点建议 我配置的IIS,为什么只能读数据库,不能写入?为什么? 我要去招商行笔试了,有参加过的兄弟给点建议。 好久没发帖了……………… 请问LINUX/UNIX下那种扩展名的文件是可执行的?DOS的。EXE对应的格式是什么? C++入门看什么书好? c++一问题 方程2的x次方=3-2x的解为x1,方程log2(x)=3-2x的解为x2,求x1+x2的值答案是3/2,可是我怎么都是2啊? 已知2+根号3是方程x2-4x+c的一个根,求方程的另一个根及c的值 无论x取何值,多项式(m-1)x的3次方+2mx的2次方+(m+1)x+p都等于px的2次方-qx+p,求(m+p)的p-q的值? 设方程2的-x次方=lgx绝对值的两个根为x1,x2,则x1乘以x2的积与0,1的大小关系 已知关于X的一元二次方程x的平方+(m+3)+m+1=0.若X1,X2是原方程的根,且|X1-X2|=二倍根号二.求m的值 当x等于3时,代数式px的3次方+qx+1的值为2002,当x等于-3时,求代数式px的3次方+qx+1的值 关于x的二次方程2x^2+(log2为底,m为真)x+log2为底根号m为真=0有两个实数根,求m的值两个相等的实数根。。对不起啊,少打两个字。。 x1、x2是方程x^+根号p*x+q=0的两个根且x1^+x1x2+x2^=3/2,1/x1^+1/x2^=5/2,求p、q的值 设x1、x2是关于x的方程x²+px+q=0的两根,x1+1、x2+1是关于x的x²+qx+p=0的两根,求p、q的值 若关于x的方程(根号x+3)+2x+m=0只有一个实数根,求m的取值范围 方程根号4-x2=lgx的根个数是几个? 已知X²+PX+q=O的两根之差等于方程X²+qX+P=0的两根之差那么除去P²-4q>0与q²-4P>0之外,P与q还应具有关系式 已知关于方程x^2+2x+2根号(x^2+2x+2p) -p^2=0,其中p为实数(1)若方程没有实数根,求p的范围(2)若p>0,为p为何值时,方程只有一个实数根,并求出这个根用换元法设根号中为a,我想知道分解因式后 已知X1,X2为方程X的平方加px加q等于0的两根,且X1加X2等于6,X1的平方加X2的平方等于20求p和q的值? 关于x的一元二次方程x²+px+q=0的两根分别为x1=-3 x2=1,求p和q的值? log根号2^(x-5)log2^(x-1) 已知关于X的方程x^2-px+q=0的两根分别为x1,x2,且x1^2+x2^2=7,1/x1+1/x2=3,求p+q的值 如果关于x的一元二次方程x的平方+px+q=0的两根分别为x1=2,x2=1,那么p、q的值分别是A 、3,2 B、3,-2 C、2,-3 D、2,3应该选哪个我想知道过程是如何解 log2(1+根号2+根号3)+log2(1+根号2 -根号3) 已知关于x的方程x²-px+q=0两根为x1、x2,则-x²+px-q=0等于多少A、-(x+x1)(x+x2)B、(x+x1)(x-x2)C、-(x-x1)(x-x2)C、(x-x1)(x+x1)选哪一个?最好有过程 已知、x1=2+3i是实系数一元二次方程x²+px+q=0的一个根求实数p,q及另一个跟x2 已知函数f(x)=2^x+x,g(x)=x-log1/2x(1/2为底数),h(x)=log2x-根号x(2为底数)的零点是x1,x2,x3,比较大小 已知三角形ABC的一边长为5,另外两边长恰是方程2x^2-12x+m+1=0的两根,求实数m的取值范围已知方程x^2+px+q=0的两个实数根分别比方程x^2+qx+p=0的两实数根小1,求以1/p,1/q为两根的一元二次方程 如果关于x的一元二次方程x2+px+q=0的两根分别为x1=3、x2=1,那么这个一元二次方程是( )A.x2+3x+4=0 B.x2-4x+3=0 C.x2+4x-3=0 D.x2+3x-4=0 已知x∈[根号2,8],函数f(x)=log2 (x/2)乘以log根号2 ((根号x)/2)求该函数的最大值与最小值,注:这两个对数式是相乘,底数分别是2和(根号2),真数分别是 (x÷2)与 (根号x÷2),在10月23日下午3 已知关于x的一元二次方程x2+px+q=0的两个实数根为p.q,则p,q=? 已知关于x的方程x²+px+q=0的两个根为x1=3,x2=4,则二次三项式x²-px+q可分解为: 已知函数f(x)=log2(2^x+1),g(x)=log2(2^x-1),若关于x的函数F(x)=g(x)-f(x)-m在[1,2]上有零点,求m范围 已知方程x^2+px+q=0的两根是a,b.求证:一元二次方程qx^2+p(1+q)x+(1+q)^2=0的根为a+1/b和b+1/a如题. 若二次三项式x²-px+q可以分解为(x-1)(x+2),那么方程x²-px+q=0的两个实数根是 若关于x的方程根号下1-x^2=log2(x-a)有正数解,则实数a的取值范围 设x1,x2是方程x²+px+q=0的两实数,x1+1,x2+1是关于x的方程x²+qx+p=0的两实跟,则p=?q=? 已知关于x的方程x²-px+q的两个根是x₁=1,x₂=-2,则二次三项式x²-px+q请用语言说明为什么 关于X的方程根号下1-X^2=x+a在区间[1,1]上有解,则实数a的取值范围是 若p,q为正实数,且关于x的方程x2+px+q=0与x2+qx+p=0均有实根,求p+q的最小值cdinten 你的答案不对恶,把4代进去就是错的。 若多项式x²+px+q可分解为(x+a)(x+b)则方程x²+px+q=0的根为x1 x2 使得方程根号(16-x^2)-x-m=0有实数解,则实数m的取值范围?答案是4≤m≤4根号2.这个好像要画图!麻烦给个图解, 方程x的平方+px+q=0的解集是A,方程X的平方+qx+2p=0的解集是B,又AnB={-1},求AUB 已知关于x的方程2x²+px+q=0的两根为x=2,x=-3,则二次三项式2x²+px+q可以因式分解为 已知全集U=R A={x f(x)=根号(X-1)(X-2)} B={x log2(X-a) 若方程x^2+px+q=0与x^2+qx+p=0有一公共根,且p不等于q,求(p+q)^2009的值答出来还送积分哦~加油.. 已知关于x的方程x^2+px+q=0的两根为x1=3,x2=-4,则二次三项式x^2+px+q可分解为 已知函数f(x)=log2(x^2-ax-a)在区间(-∞ ,1减根号3]是单调递减函数.求实数a的取值范围 一元二次方程px平方+qx平方+r=0(p不等于0)的两根为0和-1,则q:p= 已知关于x的一元二次方程kx²-px-3=0的二根分别为x1,x2,其中(1/x1+1/x2)²=4,求k,q的值 已知a>0a≠1,试求使方程log2(x-ka)=log2根号下(x^2-a^2)有解的k的取值范围希望得到图象法的解释,谢 已知方程x^2+px+q=0的一个根与方程x^2+qx-p=0的一个根互为相反数,并且p不等于q,求p-q的值. 关于x的一元二次方程x^2-px-p=0有两实数根x1,x2,若x1^2+x2^2=3,则p的取值是 已知2a的y+5次方b的3x次方与2分之5a的2x次方b的2-4y次方是同类项则x=【】,y=【】 若log2(2-a)/根号(a-1)有意义,则a的取值范围 已知:方程x^2+px+q=0的两个根为a,b,而a+1和b+1是关于x的方程x^2+qx+p=0的两根,求p,q的值. 已知关于x的方程2x^2+(log2m)x+log2根号m=0,有两个相等的实数根,求m的值 设关于方程4^x-2^x+1-b=0,若方程有实数解,求实数b的取值范围 以知关于X的方程 X的平方-pX+qX=0 的两个根是2和-3,求p,q的值. 若方程(1/2)^x=log2(X)的解为x1,方程(1/2)^x=log1/2X的解为x2,则x1x2的取值范围为若方程(1/2)的x次方=log以2为底x的对数的解为X1,若方程(1/2)的x次方=log以1/2为底X的对数的解为x2,则x1.x2的取值范围是什么 方程根号下(4-x^2)=lgx的根的个数是请把步骤写得清楚点,谢谢 如果x=3时,代数式px的3次方+qx+1的值为2008,则当x等于-3时px的3次方+qx+1 若x1,x2为方程【2的x次方=(1/2)的-1/x+1次方】的两个实数解,则x1+x2= 方程根号下4-x^2=lg x的根的个数4-x^2都在根号里 当x=-2时,代数式px的3次方+qx+1的值等于2012,那么当x=2时,代数式px+qx+1的值为多少?错了,当x=-2时,代数式px的3次方+qx+1的值等于2012,那么当x=2时,代数式px的3次方+qx+1的值为多少?四个选项A.2010 B.-201
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn